I'm trying to write a DataFrame to an Excel file using xlsxwriter and am having some issues with NaN values not being filled properly.
Regardless of whether I use df.fillna
, df.replace
or the na_rep
option on the writer, a few columns retain any NaN values in the DataFrame.
Investigating using pdb.set_trace()
, I found the following:
(Pdb) df['col_name'][0]
Decimal('NaN')
(Pdb) Decimal(np.nan)
Decimal('NaN')
(Pdb) df['col_name'][0]==Decimal(np.nan)
False
(Pdb) na=df['col_name'][0]
(Pdb) na
Decimal('NaN')
(Pdb) na==df['col_name'][0]
False
(Pdb) df['col_name'][0]
Decimal('NaN')
How can I identify these values to replace them if I can't define them?