Data Science Explorer

Pandas Read CSV 본문

Python

Pandas Read CSV

grace21110 2023. 10. 28. 22:38
반응형

CSV files (comma separated files) are used to store big data sets. 

 

Example 

Load the CSV into a DataFrame.

import pandas as pd 
df = pd.read_csv('data.csv')

print(df.to_string())

** to_string() is to print the entire DataFrame. **

 

  • max_rows 

If you want to check your system's max rows with the pd.options.display.max_rows statement. 

 

Example 

Check the number of maximum returned rows. 

import pandas as pd 

print (pd.options.display.max_rows)

** In my system the number 80, which means that if the DataFrame contains more than 80 rows, the pinrt (df) statement will return only the headers and the first and last 5 rows. ** 

 

Exercise 

Increase the maximum number of rows to display the entire DataFrame:

import pandas as pd

pd.options.display.max_rows = 80

df = pd.read_csv('data.csv')

print(df)

'Python' 카테고리의 다른 글

Pandas: Cleaning Data of Wrong Format  (0) 2023.10.29
Pandas: Cleaning Empty Cells  (2) 2023.10.29
Pandas DataFrames  (2) 2023.10.27
Pandas Series  (0) 2023.10.26
Pandas  (0) 2023.10.25