DataFrame — Pandas' core table
DataFrame is a table-like data structure with rows and columns. It's conceptually the same as an Excel spreadsheet, a database table, or a CSV file. In most Pandas projects, the DataFrame is the main object you'll be working with.
python
import pandas as pd
data = {
"Name": ["Alice", "Bob", "Charlie"],
"Age": [25, 30, 35],
"City": ["New York", "Paris", "London"]
}
df = pd.DataFrame(data)
print(df)The keys in the dictionary — Name, Age, City — become the column names. The values in the lists become the row data. Once you've created a DataFrame, you can select columns, filter it, and calculate statistics right away.
You should see
Name Age City 0 Alice 25 New York 1 Bob 30 Paris 2 Charlie 35 LondonInfo
Each column's list needs to be the same length. Name has 3 items but Age only has 2, you won't be able to build the DataFrame.