0
0
Pandasdata~10 mins

Interpolation for missing values in Pandas - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to fill missing values in the DataFrame using interpolation.

Pandas
df['column'] = df['column'].[1]()
Drag options to blanks, or click blank then click option'
Ainterpolate
Bfillna
Cdropna
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using fillna() which replaces missing values but does not estimate intermediate values.
Using dropna() which removes rows with missing values instead of filling them.
2fill in blank
medium

Complete the code to interpolate missing values using linear method along the index.

Pandas
df['column'] = df['column'].interpolate(method=[1])
Drag options to blanks, or click blank then click option'
A'nearest'
B'polynomial'
C'linear'
D'spline'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'nearest' which fills missing values with the nearest valid value.
Choosing 'polynomial' or 'spline' which require additional parameters.
3fill in blank
hard

Fix the error in the code to interpolate missing values along columns instead of rows.

Pandas
df.interpolate(axis=[1], inplace=True)
Drag options to blanks, or click blank then click option'
A0
B1
C'index'
D'columns'
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis=0 which interpolates vertically along rows.
Using string values 'index' or 'columns' which are not valid for axis parameter.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Pandas
{word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Comparing the word string directly to a number.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their values only if value is positive.

Pandas
{ [1]: [2] for [3] in data.items() if [2] > 0 }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck, v
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'item' instead of unpacking key and value.
Not converting keys to uppercase.