0
0
Pandasdata~10 mins

Forward fill and backward fill 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 forward in the DataFrame column.

Pandas
df['A'] = df['A'].[1]()
Drag options to blanks, or click blank then click option'
Afillna
Bffill
Cbfill
Ddropna
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bfill' which fills missing values backward.
Using 'fillna' without specifying method.
Using 'dropna' which removes missing values instead of filling.
2fill in blank
medium

Complete the code to fill missing values backward in the DataFrame column.

Pandas
df['B'] = df['B'].[1]()
Drag options to blanks, or click blank then click option'
Afillna
Bdropna
Cbfill
Dffill
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ffill' which fills missing values forward.
Using 'fillna' without specifying method.
Using 'dropna' which removes missing values instead of filling.
3fill in blank
hard

Fix the error in the code to forward fill missing values in the DataFrame.

Pandas
df.fillna(method=[1], inplace=True)
Drag options to blanks, or click blank then click option'
A'ffill'
B'backward'
C'forward'
D'bfill'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'forward' instead of 'ffill'.
Using 'backward' or 'bfill' which fills backward.
Using method names without quotes.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if the 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.
Checking if the word is greater than 3 instead of its length.
Using incorrect comparison operators.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their counts only if the count is greater than 0.

Pandas
{ [1]: [2] for [3], [2] 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 the original key instead of uppercase.
Using wrong variable names in the loop.
Not filtering values greater than 0.