Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load data from a CSV file.
Data Analysis Python
import pandas as pd data = pd.read_csv([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name
Using wrong function names
✗ Incorrect
The file path must be a string, so it needs quotes around it.
2fill in blank
mediumComplete the code to check for missing values in the data.
Data Analysis Python
missing = data.[1]().sum()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using dropna() which removes missing values instead of detecting them
Using notnull() which detects non-missing values
✗ Incorrect
The isna() function returns True for missing values, which we sum to count them.
3fill in blank
hardFix the error in the code to remove duplicate rows.
Data Analysis Python
clean_data = data.[1](keep='first')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using dropna which removes missing values, not duplicates
Misspelling the function name
✗ Incorrect
The correct pandas function to remove duplicate rows is drop_duplicates().
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 3 letters.
Data Analysis Python
lengths = {word: [1] for word in words if len(word) [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length
Using < instead of > in the condition
✗ Incorrect
We want the length of each word as the value, and only words longer than 3 letters, so use len(word) and >.
5fill in blank
hardFill all three blanks to create a dictionary of uppercase words and their counts if count is positive.
Data Analysis Python
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper()
Using < instead of > in the condition
Swapping keys and values
✗ Incorrect
We want keys as uppercase words (k.upper()), values as counts (v), and filter counts greater than zero (v > 0).