0
0
Data Analysis Pythondata~10 mins

Interpolation for missing numerics in Data Analysis Python - 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 'score' column using linear interpolation.

Data Analysis Python
df['score'] = df['score'].[1]()
Drag options to blanks, or click blank then click option'
Adropna
Binterpolate
Cfillna
Dreplace
Attempts:
3 left
💡 Hint
Common Mistakes
Using fillna() without specifying a value does not estimate missing values.
dropna() removes rows instead of filling missing values.
2fill in blank
medium

Complete the code to interpolate missing values in the 'temperature' column using the 'time' method.

Data Analysis Python
df['temperature'] = df['temperature'].interpolate(method=[1])
Drag options to blanks, or click blank then click option'
A'time'
B'linear'
C'nearest'
D'index'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'linear' method when the index is a time series.
Using 'nearest' which picks closest values instead of interpolating.
3fill in blank
hard

Fix the error in the code to interpolate missing values forward in the 'humidity' column.

Data Analysis Python
df['humidity'] = df['humidity'].interpolate(method=[1], limit_direction='forward')
Drag options to blanks, or click blank then click option'
A'backfill'
B'pad'
C'ffill'
D'nearest'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pad' which is an alias but not accepted by interpolate() method.
Using 'backfill' which fills backward, opposite of forward.
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.

Data Analysis Python
lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Blen(word) > 3
Cword
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' instead of 'len(word)' for values.
Using 'word > 3' which compares string to number causing error.
5fill in blank
hard

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

Data Analysis Python
result = [1]: [2] for [3] in data.items() if [2] > 0}}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'item' instead of 'k' or 'v' causing errors.
Not converting keys to uppercase.