0
0
Data Analysis Pythondata~10 mins

Single and multiple column grouping in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to group the DataFrame by the 'Category' column.

Data Analysis Python
grouped = df.groupby([1])
Drag options to blanks, or click blank then click option'
A'Date'
B'Value'
C'Category'
D'Index'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name that does not exist in the DataFrame.
Not using quotes around the column name.
2fill in blank
medium

Complete the code to group the DataFrame by both 'Category' and 'Region' columns.

Data Analysis Python
grouped = df.groupby([1])
Drag options to blanks, or click blank then click option'
A('Category', 'Region')
B'Category'
C'Category, Region'
D['Category', 'Region']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single string with comma-separated column names.
Using a tuple instead of a list.
3fill in blank
hard

Fix the error in the code to correctly group by 'Category' and calculate the mean.

Data Analysis Python
result = df.groupby([1]).mean()
Drag options to blanks, or click blank then click option'
A['Category']
B'Category'
CCategory
D'Category', 'Region'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing multiple columns as separate arguments without a list.
Not using quotes around the column name.
4fill in blank
hard

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

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'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the condition.
Using the word itself instead of its length as the value.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys, values, and filter condition.

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'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'k' instead of 'k.upper()' for keys.
Using '<' instead of '>' in the condition.