How to avoid Python/Pandas creating an index in a saved csv?
I want to save a CSV to a folder after making some edits to the file.
Every time I use pd.to_csv('C:/Path of file.csv') the CSV file has a separate column of indexes. I want to avoid printing the index to CSV.
I tried:
pd.read_csv('C:/Path to file to edit.csv', index_col = False)
And to save the file...
pd.to_csv('C:/Path to save edited file.csv', index_col = False)
However, I still got the unwanted index column. How can I avoid this when I save my files?
There are many ways to avoid Python/Pandas creating an index in CSV, some of the important ways to generate pandas to csv no index are as follows:-
The first and most preferable way would be to set your index value as index=False while you are converting your data frame into CSV below is an example that shows how to do it.