Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load the CSV file into a DataFrame.
Pandas
import pandas as pd df = pd.[1]('data.csv')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'to_csv' which saves data instead of loading it.
Using 'read_excel' which is for Excel files.
✗ Incorrect
Use pd.read_csv to load CSV files into a DataFrame.
2fill in blank
mediumComplete the code to remove rows with missing values.
Pandas
clean_df = df.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fillna' which fills missing values instead of removing rows.
Using 'isnull' which checks for missing values but does not remove rows.
✗ Incorrect
dropna() removes rows with missing values.
3fill in blank
hardFix the error in the code to convert a column to lowercase.
Pandas
df['Name'] = df['Name'].[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'upper' which converts to uppercase.
Using 'capitalize' which only changes the first letter.
✗ Incorrect
Use lower() to convert text to lowercase.
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 3 letters.
Pandas
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 '<' instead of '>' causing wrong filtering.
Using 'word' instead of 'len(word)' as dictionary value.
✗ Incorrect
The dictionary maps each word to its length if the word is longer than 3 letters.
5fill in blank
hardFill all three blanks to create a filtered dictionary with uppercase keys and values greater than 0.
Pandas
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()' for keys.
Using '<' instead of '>' in the condition.
Using 'k' instead of 'v' as dictionary values.
✗ Incorrect
This dictionary comprehension creates keys as uppercase strings and includes only items with values greater than zero.