I am writing a CSV file in python using the following line:
data.to_csv(mydata.csv)
Unfortunately, the output presents a useless column as follow:
Date median ori
0 2000年01月31日 0.159 0.182900
1 2000年02月29日 0.153 0.171349
2 2000年03月31日 0.152 0.162461
3 2000年04月30日 0.150 0.152306
4 2000年05月31日 0.167 0.141220
5 2000年06月30日 0.174 0.137749
6 2000年07月31日 0.169 0.138802
7 2000年08月31日 0.164 0.150315
How can I get rid of this useless first column?
asked Sep 19, 2018 at 17:26
steve
5412 gold badges14 silver badges35 bronze badges
1 Answer 1
data.to_csv("mydava.csv", index=False)
That should do it. Here's the documentation.
https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html
answered Sep 19, 2018 at 17:28
ltd9938
1,4541 gold badge17 silver badges29 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
data.to_csv('mydata.csv', index=False). Explained in docs: pandas.pydata.org/pandas-docs/version/0.23/generated/…index=False