

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: What Is Pandas?
incomplete
2: Series
incomplete
3: DataFrames
incomplete
4: Derived Columns
incomplete
5: Series vs. DataFrame
incomplete
6: Filtering Data
incomplete
7: The Index in Pandas
incomplete
8: Custom Indexes
incomplete
9: Loading Data
incomplete
10: Inspect Head
incomplete
11: Info & Describe
incomplete
12: Inspecting Workflow
incomplete
13: Data Properties
incomplete
14: Inspecting Columns
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Never start manipulating data without inspecting it first. In the real world, data gets messy. Inspection reveals:
Missing values that could break your analysis
Wrong data types (e.g., numbers stored as text)
Unexpected values (negative prices, dates far in the future)
Inconsistent column names
Skipping inspection leads to bugs that are hard to track down later.
The .head() method is straightforward: it returns a new DataFrame with just the first few rows. Use this to get a quick look at your data's shape, to see if it even makes sense.
head_df = df.head() # Returns the first 5 rows (default setting)
print(head_df)Which prints something like this:
dish price ordered_at
0 Carbonara 16.5 2024-03-02 18:30
1 Margherita 12.0 2024-03-02 18:45
2 Tiramisu 7.5 2024-03-02 19:00
3 Bruschetta 6.0 2024-03-02 19:15
4 Negroni 11.0 2024-03-02 19:30You can optionally pass a number to .head() to get a different number of rows:
df.head(10) # Returns the first 10 rowsSnackStack's operations team sometimes needs a quick sample of incoming sensor data before processing a full batch. Complete the preview_devices function. It accepts a DataFrame and a row count n, and returns the first n rows with only the "device_id" and "temperature" columns.