I am working with a df and using numpy to transform data - including setting blanks (or \'\') to NaN. But when I write the df to csv - the output contains the string \'nan\' as
Pandas to the rescue, use na_rep to fix your own representation for NaNs.
na_rep
df.to_csv('file.csv', na_rep='NULL')
file.csv
,index,x,y,z 0,0,1.0,NULL,2 1,1,NULL,3.0,4