Creating DataFrames
A DataFrame is a two-dimensional table with labeled rows and columns. It's the primary data structure in Pandas.
From a Dictionary of Lists
The most common way to create a DataFrame:
Loading Pandas Playground...
From a List of Dictionaries
Each dictionary becomes a row:
Loading Pandas Playground...
With Custom Index
Specify custom row labels:
Loading Pandas Playground...
From NumPy Arrays
Create from 2D arrays with column names:
Loading Pandas Playground...
Creating Empty DataFrames
Start with an empty structure and fill it:
Loading Pandas Playground...
Exercise: Student Records
Loading Exercise...
Exercise: From List of Dicts
Loading Exercise...
Key Points
- DataFrames are 2D labeled data structures
- Create from dict of lists (columns) or list of dicts (rows)
- Use
index=for custom row labels - Use
columns=for custom column names - Can create empty DataFrames and add data later

