1
我正在寫幾個數據框到不同的工作表中的excel文件。 我需要將0值僅視爲空白,但不包含0.006,10.02%,其中包含0作爲空白。像這樣pandas dataframe xlsxwriter寫入excel:將零視爲空白
0 blank
0.02 0.02 not affected
10.02% 10.02% not affected
謝謝。
我正在寫幾個數據框到不同的工作表中的excel文件。 我需要將0值僅視爲空白,但不包含0.006,10.02%,其中包含0作爲空白。像這樣pandas dataframe xlsxwriter寫入excel:將零視爲空白
0 blank
0.02 0.02 not affected
10.02% 10.02% not affected
謝謝。
用np.nan
替換零再寫入excel。 to_excel
默認情況下,np.nan
作爲''
df.mask(df.eq(0)).to_excel()