CSV (comma separated values) is a text-only spreadsheet format. Most database and spreadsheet programs can use them or create them.
column1,column2,column3
value1,value2,value3
We can load CSV into a DataFrame in Pandas using pd.read_csv()
pd.read_csv('csv-file.csv')
We can display a DataFrame with a print()
function.
For example: To read the CSV ‘sample.csv’ into a variable called df, we use the following code:
import pandas as pd
df = pd.read_csv('sample.csv')
print(df)
When we print DataFrame, we can see all rows of DataFrame.
We can also save data to a CSV, using .to_csv()
df.to_csv('new-csv-file.csv')