<jupyter_start><jupyter_text>Homework 1 - <NAME><jupyter_code>#display all outputs
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
#import libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#Read the CSV file into a pandas dataframe. (1 pt)
bike_df = pd.read_csv('../data/65db-xm6k.csv')

#quick look at data
bike_df.head()
bike_df.shape
#check types
bike_df.dtypes
#coerce date column to a datetime format - can infer format as small df
bike_df.Date = pd.to_datetime(bike_df.Date, infer_datetime_format=True)
#Add columns to the dataframe containing: ( 3 pt)
#The total (East + West) bicycle count
bike_df["total_count"] = bike_df["Fremont Bridge East Sidewalk"] + bike_df["Fremont Bridge West Sidewalk"]
#The hour of the day
bike_df['hour_of_day'] = bike_df.Date.dt.hour
#The year
bike_df['year'] = bike_df.Date.dt.year

#Create a dataframe with the subset of data from the year 2016 (1 pt)
bike_df_subset = bike_df[bike_df['year']==2016]
#check max and min dates...
min(bike_df_subset.Date)
max(bike_df_subset.Date)
#Use pandas + matplotlib to plot the counts by hour. (i.e. hour of the day on the x-axis, total daily counts on the y-axis) (1 pt)
#assuming that that single grouped series is preferred to a yearly series

#create grouped df
graph_df = bike_df[['hour_of_day','total_count']].groupby(by="hour_of_day").sum()

#plot
%matplotlib inline
plt.bar(graph_df.index, graph_df.total_count, color='green')
plt.xlabel("Hour of day")
plt.ylabel("Count")
plt.title("Counts of bicycles crossing the Fremont Bridge by hour (2012-date)")
plt.figtext(0.99, 0.01, 'Source: City of Seattle Open Data', horizontalalignment='right')
plt.show()
#Use pandas to determine what is (on average) the busiest hour of the day (1 pt)
bike_df[['hour_of_day','total_count']].groupby(by="hour_of_day").mean().sort_values("total_count",ascending=False)

#5pm-6pm is on average the busiest hour of the day
#(by total crossing count, and based on an interpretation of the metadata about the Date field)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11084681255946717, 'fraction_numerical': 0.01379638439581351, 'mean_word_length': 5.872549019607843, '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': '171499', 'license': 'MIT', 'n_tokens_mistral': 755, 'n_tokens_neox': 718, 'n_words': 234, 'path': 'project/analysis/homework_1_analysis.ipynb', 'repo_name': 'uwseds-sp20/homework-1-manipulating-data-rcctodd', 'size': '2108'}