pandas DataFrame
A DataFrame is a labeled two-dimensional table whose columns can contain different data types.
What is pandas DataFrame?
A DataFrame is a labeled two-dimensional table whose columns can contain different data types.
Create and inspect a pandas DataFrame in an online Python IDE.
When should you use it?
- Read, clean, and transform tabular data.
- Analyze data from CSV, Excel, APIs, or databases.
- Prepare reports, statistics, and chart data.
Example code
main.py
import pandas as pd
students = pd.DataFrame({
"name": ["Ada", "Lin", "Sam"],
"score": [95, 88, 91],
})
print(students)
Expected output
name score
0 Ada 95
1 Lin 88
2 Sam 91
How it works
A dictionary of equally sized lists becomes a DataFrame. Each dictionary key supplies a column label.
Change the values and run the program in the CodeUtility online Python compiler without installing Python locally.
Practice exercises
Modify the runnable example with the exercises below to build understanding beyond copying the result.
- Add rows, columns, and missing values.
- Combine filtering, sorting, and groupby into a small report.
- Load a real file, inspect dtypes, and handle invalid data.