最佳答案
I'm having trouble getting the pandas dataframe.to_csv(...)
output quoting strings right.
import pandas as pd
text = 'this is "out text"'
df = pd.DataFrame(index=['1'],columns=['1','2'])
df.loc['1','1']=123
df.loc['1','2']=text
df.to_csv('foo.txt',index=False,header=False)
The output is:
123,"this is ""out text"""
But I would like:
123,this is "out text"
Does anyone know how to get this right?