I think you can use fillna:
df = df.fillna(0)
or
df['A'] = df['A'].fillna(0)
But it is better to use to_excel:
import pandas as pd
import numpy as np
df = pd.DataFrame({'A': [10, 20, 30, 20, 15, 30, 45, np.nan],
'B': [10, 20, 30, 20, 15, 30, 45, np.nan]})
print df
A B
0 10 10
1 20 20
2 30 30
3 20 20
4 15 15
5 30 30
6 45 45
7 NaN NaN
df1 = df[['A']]
writer = pd.ExcelWriter('f_name.xlsx', engine='xlsxwriter')
df1.to_excel(writer, sheet_name='PnL', na_rep=0)
If you want to omit the index and title, add options index=Falseand header=False:
df1.to_excel(writer, sheet_name='PnL', na_rep=0, index=False, header=False)

source
share