<jupyter_start><jupyter_text>Author: <NAME> Date: October 19, 2020 Course CSE 583 Homework 1 1. Read the CSV file into a pandas dataframe (1pt)<jupyter_code>import pandas as pd
import numpy as np

#left data as a subdirectory of analysis so this would run automatically without have an absolute path
df = pd.read_csv(r"data/rawData.csv")
df.head()
df.dtypes<jupyter_output><empty_output><jupyter_text>2. Add columns to the dataframe containing:  * The total (East + West) bicycle count (1pt)  * The hour of the day (1pt)  * The year (1pt)<jupyter_code>#the total column already exists! But I'll make a new one anyway.
df['total_eastWest_bikeCount'] = df['Fremont Bridge East Sidewalk'] + df['Fremont Bridge West Sidewalk']
df.head()
from datetime import datetime

df['Date_datetime'] =  pd.to_datetime(df['Date'])
df['hour'] = df['Date_datetime'].dt.hour
df['year'] = df['Date_datetime'].dt.year
df.head(20)<jupyter_output><empty_output><jupyter_text>3. Create a dataframe with the subset of data from the year 2016 (1pt)<jupyter_code>df_2016 = df[(df['year'] == 2016)]
print('unique years in df_2016:', df_2016['year'].unique())
print('unique years in df:', df['year'].unique())<jupyter_output>unique years in df_2016: [2016]
unique years in df: [2012 2013 2014 2015 2016 2017 2018 2019 2020]<jupyter_text>4. 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) (1pt)<jupyter_code>#FYI there is bias in the number of rows by hour, but anyway I'm not going to adjust for it.
count = df.groupby(['hour', ]).size()
print(count)
df_hoursGrouped = df.groupby(['hour'], as_index=False)
df_hourGrouped_ForViz = df_hoursGrouped.agg({'total_eastWest_bikeCount':[np.sum, np.mean]})
df_hourGrouped_ForViz.head()

df_hourGrouped_ForViz.columns = list(map(''.join, df_hourGrouped_ForViz.columns.values))
import pandas as pd

import matplotlib.pyplot as plot

df_hourGrouped_ForViz.plot.bar(x="hour", y='total_eastWest_bikeCountsum', title="Counts of Cyclist by hour from 2012-2020 on the Fremont Bridge");
plot.show(block=True);<jupyter_output><empty_output><jupyter_text>5. Use pandas to determine what is (on average) the busiest hour of the day (1pt)<jupyter_code>df_hourGrouped_ForViz.sort_values(by=['total_eastWest_bikeCountmean'], ascending=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12211784799316823, 'fraction_numerical': 0.04099060631938514, 'mean_word_length': 6.58252427184466, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '252650', 'license': 'MIT', 'n_tokens_mistral': 901, 'n_tokens_neox': 803, 'n_words': 240, 'path': 'project/analysis/hw1_jasonThomas.ipynb', 'repo_name': 'UWSEDS/homework-0-testing-jatjasonthomas', 'size': '2348'}