<jupyter_start><jupyter_text>Data 515 Homework 1  <NAME>   1**Read the CSV file into a pandas dataframe. (1 pt)**<jupyter_code>import pandas as pd
bicycle = pd.read_csv('../data/bicycle.csv')
bicycle.head(10)<jupyter_output><empty_output><jupyter_text>2**Add columns to the dataframe containing: (3 pt)** i. The total (East + West) bicycle count<jupyter_code># Total bicycle count = eEast bicycle count + West bicycle count
bicycle['Total Bicycle Count'] = bicycle['Fremont Bridge East Sidewalk'] + bicycle['Fremont Bridge West Sidewalk']
bicycle.head(10)<jupyter_output><empty_output><jupyter_text>ii. The hour of the day<jupyter_code># Convert 'Date' from string to datetime
dates = pd.to_datetime(bicycle['Date'])
# Extract hour from 'Date'
bicycle['Hour'] = dates.dt.hour
bicycle.head(10)<jupyter_output><empty_output><jupyter_text>iii. The year<jupyter_code># Extract year from 'Date'
bicycle['Year'] = dates.dt.year
bicycle.head(10)<jupyter_output><empty_output><jupyter_text>3**Create a dataframe with the subset of data from the year 2016 (1 pt)**<jupyter_code># Subset the bicycle dataframe where the year is 2016
bicycle_2016 = bicycle[bicycle['Year']==2016]
bicycle_2016.head(10)<jupyter_output><empty_output><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) (1 pt)**<jupyter_code># Group bicycle dateframe by 'Hour'
# Compute the sum of total bicycle counts
byHour = bicycle_2016[['Hour','Total Bicycle Count']].groupby(['Hour']).sum()
byHour
import matplotlib.pyplot as plt
%matplotlib inline
# Plot the total daily counts by hour of the day
temp = plt.bar(byHour.index, byHour['Total Bicycle Count'])
temp = plt.xlabel('Hour')
temp = plt.ylabel('Counts')
temp = plt.title('Total Daily Counts by Hour of the Day')
plt.show()<jupyter_output><empty_output><jupyter_text>5**Use pandas to determine what is (on average) the busiest hour of the day (1 pt)**<jupyter_code># Group bicycle dateframe by 'Hour'
# Compute average total bicycle counts
# Sort by average total bicycle counts in descending order
# Display the top one 'Hour'
bicycle_2016.groupby(['Hour']).mean().sort_values('Total Bicycle Count', ascending=False).head(1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12350597609561753, 'fraction_numerical': 0.023461708720672863, 'mean_word_length': 6.739726027397261, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '372422', 'license': 'MIT', 'n_tokens_mistral': 838, 'n_tokens_neox': 774, 'n_words': 229, 'path': 'project/analysis/bicycle-analysis-Cathy.ipynb', 'repo_name': 'UWSEDS/manipulating-data-in-python-cathyyyyjia', 'size': '2262'}