<jupyter_start><jupyter_text>Page View Time Series Visualizer Project<jupyter_code>import pandas as pd 
import numpy as np 
import seaborn as sns 
import matplotlib.pyplot as plt

#import csv 

df = pd.read_csv('/content/sample_data/fcc-forum-pageviews.csv', parse_dates=['date'], index_col='date')
df.head()
# df.value.count()
#Clean the data by filtering out days when the page views were in the top 2.5% of the dataset or bottom 2.5% of the dataset.

df = df[
                  (df['value'] >= df['value'].quantile(0.025)) & 
                  (df['value'] <= df['value'].quantile(0.975))]
# df.value.count()
df


#Create a draw_line_plot function that uses Matplotlib to draw a line chart similar to "examples/Figure_1.png". 
# The title should be "Daily freeCodeCamp Forum Page Views 5/2016-12/2019". 
# The label on the x axis should be "Date" and the label on the y axis should be "Page Views".

fig, ax = plt.subplots(figsize = (15, 5))
ax.plot(df.index, df['value'], 'r', linewidth = 1)

ax.set_title('Daily freeCodeCamp Forum Page Views 5/2016-12/2019')
ax.set_xlabel('Date')
ax.set_ylabel('Page Views')
# Create a draw_bar_plot function that draws a bar chart similar to "examples/Figure_2.png".
#  It should show average daily page views for each month grouped by year. 
#  The legend should show month labels and have a title of "Months". On the chart, the label 
# on the x axis should be "Years" and the label on the y axis should be "Average Page Views".

df['month'] = df.index.month
df['year'] = df.index.year

df_group = df.groupby(['year', 'month'])['value'].mean()
# df_group = df.groupby(['year', 'month'], as_index = False)['value'].mean()
df_group = df_group.unstack()
df_group


box_plot = df_group.plot.bar(legend=True, figsize=(10,7), xlabel='Years', ylabel= 'Average Page Views' )
plt.legend(['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'])
# Create a draw_box_plot function that uses Searborn

df_box = df.copy()
df_box
df_box.reset_index(inplace=True)
df_box
# df_box=df_box.sort_values('month')
# df_box
df_box['year'] = [d.year for d in df_box.date]
df_box
df_box['month'] = [d.strftime('%b') for d in df_box.date]
df_box
df_box=df_box.sort_values('month')
df_box
df_box['month_num'] = df_box['date'].dt.month
df_box
df_box = df_box.sort_values('month_num')
df_box 
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(10,5))
ax[0] = sns.boxplot(x=df_box['year'], y=df_box['value'], ax=ax[0])
ax[1] = sns.boxplot(x=df_box['month'], y=df_box['value'], ax = ax[1])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15485362095531588, 'fraction_numerical': 0.020030816640986132, 'mean_word_length': 4.929223744292237, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '610247', 'license': 'MIT', 'n_tokens_mistral': 998, 'n_tokens_neox': 932, 'n_words': 272, 'path': 'Projects/Page_View_Time_Series_Visualizer.ipynb', 'repo_name': 'Mukeshvudayagiri/keep-coding-python', 'size': '2596'}