Complete the code to load the web analytics data from a CSV file.
import pandas as pd data = pd.read_csv([1])
We need to provide the file name as a string, so it must be in quotes.
Complete the code to display the first 5 rows of the data.
print(data.[1]())
tail() which shows the last rows.info() which shows summary info, not rows.The head() method shows the first 5 rows by default.
Fix the error in the code to calculate the average session duration.
average_duration = data['session_duration'].[1]()
sum() which adds all values.count() which counts non-null entries.The mean() method calculates the average value.
Fill both blanks to create a dictionary of page views for pages with more than 100 views.
page_views = {page: data[data['page'] == page]['views'].[1]() for page in data['page'].unique() if data[data['page'] == page]['views'].[1]() [2] 100}mean() instead of sum().< instead of > in the condition.We sum views per page and filter pages with views greater than 100.
Fill all three blanks to create a filtered DataFrame with sessions longer than 5 minutes and sort by duration descending.
filtered = data[data['session_duration'] [1] [2]].sort_values(by=[3], ascending=False)
We filter sessions longer than 300 seconds (5 minutes) and sort by 'session_duration'.
