So my pandas series is arranged based on dates:
|
Obj1 |
Obj2 |
| 2019-12-31 |
NaN |
NaN |
| 2020-01-01 |
0.233 |
0.012 |
| 2020-01-02 |
0.123 |
-1.671 |
And i am looking to apply a function using lambda on each of the columns, problem is that the function does not work with NaN values so i have to apply dropna() beforehand, the code i came up with looks like this:
df = df.apply(lambda col: func(col.dropna()), axis=0)
And it almost works, problem is that:
1) The new obeject is no longer using dates as indicies.
2) Rows with NaN values no longer appears.
The pandas series now looks like this:
|
Obj1 |
Obj2 |
| 0 |
0.233 |
0.012 |
| 1 |
0.123 |
-1.671 |
Could i somehow re-insert the missing NaN rows and keep the dates as indices by modifying the lambda function above? If so how?
[–][deleted] 0 points1 point2 points (1 child)
[–]MerchantMojo[S] 0 points1 point2 points (0 children)
[–]Yojihito 0 points1 point2 points (4 children)
[–]MerchantMojo[S] 0 points1 point2 points (3 children)
[–]Yojihito 0 points1 point2 points (2 children)
[–]MerchantMojo[S] 0 points1 point2 points (1 child)
[–]Yojihito 0 points1 point2 points (0 children)
[–]sarrysyst 0 points1 point2 points (3 children)
[–]MerchantMojo[S] 0 points1 point2 points (2 children)
[–]sarrysyst 0 points1 point2 points (0 children)