Let’s see how to convert a DataFrame to a CSV file using the tab separator. We will be using the
to_csv() method to save a DataFrame as a csv file. To save the DataFrame with tab separators, we have to pass “\t” as the
sep parameter in the
- Import the
- Create a DataFrame using the
- Save the DataFrame as a csv file using the
to_csv()method with the parameter
- Load the newly created CSV file using the
read_csv()method as a DataFrame.
- Display the new DataFrame.
The contents of the Students.csv file are :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.