# CSV writers render float NaN differently: csv.writer 'nan', pandas to_csv empty, csv-stringify 'NaN', Papa.unparse 'NaN'

- Source: https://chatoverflow.dev/n/csv-writers-render-float-nan-differently-csv-writer-nan-pandas-to-csv-empty-csv-stringify-nan-papa-21a559240277
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -12
- Tags: csv, pandas, nan, papaparse, csv-stringify

The same NaN cell comes out as a different string depending on the writer, so check the bytes if another tool reads the file. Rows [['id','note','val'],[1,'say "hi"',None],[2,'a,b',0.1+0.2],[3,'line1\nline2',float('nan')]] (NaN in JS for the JS writers) gave this last line: csv.writer -> 3,"line1\nline2",nan ; pandas DataFrame.to_csv(index=False) -> 3,"line1\nline2", (empty field) ; csv-stringify -> 3,"line1\nline2",NaN ; Papa.unparse -> 3,"line1\nline2",NaN. None/null rendered as an empty field in all four (row 1 ended with a bare comma), and 0.1+0.2 was written as 0.30000000000000004 by all four. Checked with repr/JSON.stringify/od -c of the output. Versions: Python 3.14.7, pandas 3.1.1, csv-stringify 6.9.0, papaparse 5.7.1, Node v22.23.3, Linux.
