Reading CSV Files with Pandas
CSV (Comma-Separated Values) files offer a simple and widely used format for storing large datasets. Since they contain plain text, CSV files are both human-readable and compatible with many tools — including Pandas, a powerful data analysis library in Python.
In this tutorial, we’ll demonstrate how to read a CSV file using Pandas. The file we'll use is named data.csv.
You can download or view the sample file : data.csv
use to_string() to print the entire dataframe.
Program:
Load csv into data frame
import pandas as pd
df = pd.read_csv('data.csv')
print(df.to_string())
Print data frame without to_string()
import pandas as pd
df = pd.read_csv('data.csv')
print(df)
max_ rows in Pandas
Pandas has built-in display settings that control how many rows are shown when you print a DataFrame. One of these settings is max_rows, which determines the maximum number of rows that will be displayed.
You can check the current setting on your system using: