Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load the web analytics 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 to put the file name in quotes.
Using a variable name without defining it.
✗ Incorrect
We need to provide the file name as a string, so it must be in quotes.
2fill in blank
mediumComplete the code to display the first 5 rows of the data.
Data Analysis Python
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 calculate the average session duration.
Data Analysis Python
average_duration = data['session_duration'].[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
sum() which adds all values.Using
count() which counts non-null entries.✗ Incorrect
The mean() method calculates the average value.
4fill in blank
hardFill both blanks to create a dictionary of page views for pages with more than 100 views.
Data Analysis Python
page_views = {page: data[data['page'] == page]['views'].[1]() for page in data['page'].unique() if data[data['page'] == page]['views'].[1]() [2] 100} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
mean() instead of sum().Using
< instead of > in the condition.✗ Incorrect
We sum views per page and filter pages with views greater than 100.
5fill in blank
hardFill all three blanks to create a filtered DataFrame with sessions longer than 5 minutes and sort by duration descending.
Data Analysis Python
filtered = data[data['session_duration'] [1] [2]].sort_values(by=[3], ascending=False)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column name for sorting.
Filtering with less than or equal instead of greater than.
✗ Incorrect
We filter sessions longer than 300 seconds (5 minutes) and sort by 'session_duration'.