Search code examples
pandasdataframeexport-to-csvnasys

How to set missing value in dataframe.csv(sys.stdout, na_rep='NULL') for the first row of dataframe containing column headers(the highlighted portion)


Set missing value

Tried data.to_csv(sys.stdout,na_rep='NULL') but it doesnt apply to first row


Solution

  • That's your index's name - it cannot be ignored.

    Set index name instead using df.index.name = 'yourname' or remove the index from the to_csv using df.to_csv(index=False)