Removing index column in pandas when reading a csv
df.reset_index(drop=True, inplace=True)
When writing to and reading from a CSV file include the argument index=False
and index_col=False
, respectively. Follows an example:
To write:
df.to_csv(filename, index=False)
and to read from the csv
df.read_csv(filename, index_col=False)
This should prevent the issue so you don't need to fix it later.