DataFrame.to_csv not using correct line terminator value · Issue #20353 · pandas-dev/pandas (original) (raw)
Method 1:
data_frame.to_csv(file_path, sep=self.delimiter, float_format='%.2f',
index=False, line_terminator='\n')
Method 2:
with open(file_path, mode='w', newline='\n') as f:
data_frame.to_csv(f, sep=self.delimiter, float_format='%.2f',
index=False)
Problem description
I noticed a strange behavior when using pandas.DataFrame.to_csv method on Windows (pandas version 0.20.3). When calling the method using method 1 with a file path, it's creating a new file using the \r line terminator, I had to use method two to make it work.