

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
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
The .head() method is good for a quick "sniff test" of a new DataFrame, but you'll also want to look at summary info about the data. This is where the .info() and .describe() methods come in.
The .info() method prints a concise summary of your DataFrame.
df.info()
Prints something like this:
<class 'pandas.DataFrame'>
RangeIndex: 20 entries, 0 to 19
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 city 20 non-null object
1 price 20 non-null float64
2 sqft 19 non-null float64
dtypes: float64(2), object(1)
memory usage: 612.0 bytes
We get a bunch of useful info at once:
20)3)object, float64)sqft has 19 non-null, meaning 1 missing value)DataFrame (612.0 bytes)The .describe() method digs a bit deeper, generating descriptive statistics for numeric columns by default:
stats_df = df.describe()
print(stats_df)
This returns a new DataFrame containing the statistics. If you print it, the output will look something like this:
price sqft
count 20.000000 19.000000
mean 470250.000000 1575.263158
std 150939.818959 410.573696
min 225000.000000 880.000000
25% 373750.000000 1325.000000
50% 465000.000000 1550.000000
75% 548750.000000 1825.000000
max 815000.000000 2400.000000
count: Number of non-null (non-missing) valuesmean: Average valuestd: Standard deviation (how spread out the values are; higher = more variation)min: Minimum (smallest) value25%: First quartile (25% of values are below this)50%: Median (middle value; half of values are above, half below)75%: Third quartile (75% of values are below this)max: Maximum (largest) valueBecause .describe() returns a DataFrame, you can select from it like any other DataFrame. The .loc[] indexer selects by label instead of numeric position.
stats = df.describe()
price_stats = stats["price"]
print(price_stats.loc["mean"])
# 470250.0
SnackStack's analytics team needs the average temperature for a new batch of sensor readings, after a quick structural check. Complete the get_average_temperature function. It accepts a DataFrame, prints its info, and returns the mean temperature.