Python dataframe
时间: 2023-11-05 18:02:57 浏览: 101
A dataframe in Python is a two-dimensional labeled data structure with columns of potentially different types. It is similar to a spreadsheet or SQL table, but with more powerful querying capabilities.
A dataframe can be created in Python using the `pandas` library. Here's an example:
```python
import pandas as pd
# create a dataframe from a dictionary
data = {'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35],
'city': ['New York', 'London', 'Paris']}
df = pd.DataFrame(data)
# display the dataframe
print(df)
```
Output:
```
name age city
0 Alice 25 New York
1 Bob 30 London
2 Charlie 35 Paris
```
In this example, we created a dataframe from a dictionary where each key represents a column and its value represents the data in that column. We then printed the dataframe using the `print` function.
阅读全文