0
0
Pandasdata~10 mins

Data validation checks 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 check if there are any missing values in the DataFrame.

Pandas
missing = df.[1]()
Drag options to blanks, or click blank then click option'
Afillna
Bdropna
Cisnull
Dhead
Attempts:
3 left
💡 Hint
Common Mistakes
Using dropna() removes rows instead of checking for missing values.
Using fillna() replaces missing values but does not check for them.
2fill in blank
medium

Complete the code to count the number of missing values in each column.

Pandas
missing_counts = df.isnull().[1]()
Drag options to blanks, or click blank then click option'
Asum
Bcount
Cmean
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using count() counts non-missing values, not missing ones.
Using mean() gives proportion, not count.
3fill in blank
hard

Fix the error in the code to check if all values in column 'age' are positive.

Pandas
all_positive = (df['age'] [1] 0).all()
Drag options to blanks, or click blank then click option'
A<
B<=
C==
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' checks for negative values.
Using '==' checks for equality, not positivity.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

Pandas
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' includes shorter words, not longer.
Using 'word' as value stores the word, not its length.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase keys and values greater than zero.

Pandas
result = {{ [1]: [2] for k, v in data.items() if v [3] 0 }}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() changes keys to lowercase.
Using '<' filters for negative values.