1.使用DataFrame函数创建dataframe表
时间: 2024-05-02 13:19:47 浏览: 95
python pandas.DataFrame.loc函数使用详解
Sure, to create a DataFrame in Python using the DataFrame function, you would first import the pandas library using "import pandas as pd", then create a dictionary of your data, and finally use the DataFrame function to convert the dictionary into a DataFrame table. An example code snippet would look like this:
```
import pandas as pd
data = {'name': ['Alice', 'Bob', 'Charlie'],
'age': [24, 32, 18],
'city': ['New York', 'San Francisco', 'London']}
df = pd.DataFrame(data)
print(df)
```
This would create a DataFrame table with three columns (name, age, and city) and three rows of data for each person.
阅读全文