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 data = 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, not CSV.
✗ Incorrect
We use pd.read_csv to load CSV files into a DataFrame.
2fill in blank
mediumComplete the code to show the first 5 rows of the DataFrame.
Pandas
print(data.[1]())
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tail' which shows the last rows.
Using 'info' which shows summary info, not rows.
✗ Incorrect
The head() method shows the first 5 rows by default.
3fill in blank
hardFix the error in the code to get summary statistics of the DataFrame.
Pandas
summary = data.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'summary' or 'stats' which are not pandas methods.
Using 'info' which gives data types, not statistics.
✗ Incorrect
The describe() method returns summary statistics like mean and count.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing wrong filtering.
Using 'word' instead of 'len(word)' for the value.
✗ Incorrect
We want the length of each word (len(word)) and only words longer than 3 (len(word) > 3).
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 '>' causing wrong filtering.
✗ Incorrect
Keys are converted to uppercase with k.upper(), values are v, and we filter values greater than 0 using >.