I would like to write excel code into a python(pandas)
i have filtered the df.loc[df.Activity_Mailbox.isnull()], now the na values must be calculated using if (coloumnArow1=coloumnArow2,coulumnBrow2,"") this formula is according to excel.
CodePudding user response:
Please provide next time some demo data, like in your other question :-) If I understand you correctly. Your data looks like:
df = pd.DataFrame({"A":[1,2,3,np.nan,5,np.nan],
"B":[10,11,12,13,14,15]})
df
A B
0 1.0 10
1 2.0 11
2 3.0 12
3 NaN 13
4 5.0 14
5 NaN 15
And now you want to fill the NaN
with value from the other column. This can easily be done with:
df["A"] = df["A"].fillna(df["B"])
Output:
df
A B
0 1.0 10
1 2.0 11
2 3.0 12
3 13.0 13
4 5.0 14
5 15.0 15