I have a large panel dataframe that includes multiple assets for multiple dates. The issue is that some assets don't have values every day, so I am looking to just have any blank values for the day be replaced by the last available value for that asset.
For example:
tradeDate assetId ticker Sedol price
0 2016-01-04 00:00:00.000 1786 3900 B17N9P6 1
1 2016-01-04 00:00:00.000 2041 1898 B1JNK84 2
2 2016-01-04 00:00:00.000 2981 CBMG B9F9PM1 3
3 2016-01-04 00:00:00.000 3547 MWA B15RZR4 4
4 2016-01-04 00:00:00.000 3570 TPLM B065Y40 5
5 2016-01-05 00:00:00.000 3995 MHGC B0YRYS2 1
6 2016-01-05 00:00:00.000 4110 DSW B0BV2V6 2
7 2016-01-05 00:00:00.000 4874 NWE B03PGL4 3
8 2016-01-05 00:00:00.000 4982 BOFI B0637D4 4
9 2016-01-05 00:00:00.000 5082 ISCTR B03MYS8 5
10 2016-01-05 00:00:00.000 5083 KCHOL B03MVJ8 6
so what I need to do is index on tradeDate and assetIds, and then reindex so that it creates new rows for each tradedate so that there is always the same amount of assetIds. This will create rows with NaNs. I'm confused by this step because I'm not sure the syntax when using multiple indexes and when the columns tradeDate and assetId don't exactly match up.
Finally, I'm going to have to replace the NaNs with the last available value. However, again I have to do it for both indexes for tradeDate and assetId. Appreciate the help on this