to_csv()

noun

say it: “too SEE-ESS-VEE” /tu ˌsiˌɛsˈvi/

A pandas method that saves a table as a CSV file, a plain text file with one row per line and commas between the values.

What does to_csv() do in pandas?

to_csv() saves a table as a CSV file that any notebook, script or spreadsheet can open. Add index=False, or the row numbers are written too and come back as an extra column named Unnamed: 0.

clean.to_csv("data/clean/readings.csv", index=False)

In a sentence

  • “Without index=False, to_csv() also wrote the row numbers as a column.”
  • “to_csv() saved the cleaned readings for next week's notebook.”

Level: Apprentice · More Python terms at this level

Updated