DataFrame from Records
Intermediate · Write the code · from Pandas: Create, Load, and Explore DataFrames
From the lesson: Pandas: Create, Load, and Explore DataFrames
You have a spreadsheet with 10,000 rows of sales data. You need to find every order over $500, group them by region, and calculate the average. In Excel, that takes a pivot table, a filter, and a lot of clicking. In pandas, it takes three lines of code.
Read the lessonCreate a DataFrame called df from a list of dictionaries representing three students:
{'name': 'Alice', 'grade': 90}{'name': 'Bob', 'grade': 85}{'name': 'Charlie', 'grade': 92}Print the shape of the DataFrame using print(df.shape).
import pandas as pd
# Create DataFrame from a list of dicts
More Pandas DataFrame exercises
- Create a Named SeriesIntermediate
- Build a DataFrame from a DictionaryIntermediate
- Predict the Output: head()Intermediate
- Add a Computed ColumnIntermediate
- Fix the Bug: Column SelectionIntermediate
- Extract Stats from describe()Intermediate
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz