pd.read_csv
时间: 2023-10-18 17:16:33 浏览: 70
pd.read_csv is a function provided by the pandas library in Python. It is used to read a CSV (Comma Separated Values) file and create a DataFrame object from it. The function takes the file path as input and returns a DataFrame object. It has several parameters that can be used to customize the behavior of the function, such as delimiter, header, encoding, and more. Here's an example of how to use pd.read_csv:
```
import pandas as pd
# read the CSV file and create a DataFrame object
df = pd.read_csv('data.csv')
# display the first few rows of the DataFrame
print(df.head())
```
In this example, the data.csv file is read using pd.read_csv and a DataFrame object is created. The head() method is then called on the DataFrame to display the first few rows of the data.
阅读全文