<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 First we import some libraries. Libraries (such as matplotlib, os, pandas, urllib) allow you to do more things than with Python's base functionality. They contain functions that have specific purposes. Some libraries contain functions that allow you to calculate the minimum, maximum, mean, standard deviation and so on. Other libraries are focused on making graphs and stuff to allow you present your findings in a quick and clean way.  <br> <br>
In the following, we use
Step1:  In the section below, we first import some libraries we will use. Next, we define a variable called URL, this is a webadress to our data set. The dataset contains the number of cyclists passing over the Fremont Bridge in Seattle in both directions every hour, since 2012 (I think). <br><br>
We then define a function (remember, a function is a bunch of code that does 1 specific thing) which imports the data set from the given URL, called get_fremont_data. The function stores the data set in "data" and then spits out the data set so we can use it!
Step2:  Important to note is that if we make a function which does a thing, it doesnt do that thing untill you actually call the function, calling a function is easy
Step3:  So great! We have not imported our dataset and we know it exists because we can show it. To find out what is actually interesting about the cyclists, we can plot the weekly sum of cyclists in both directions, as well as the total number of cyclists. <br><br>
Interesting to see is the wave pattern (sinusoid) to the amount of cyclists on a yearly basis. Apparently, there are a lot fewer people who take the bycicle in the winter than there are in the summer. This isnt that surprising.
Step4:  The graph below is boring, just skip it
Step5:  The graph below shows an interesting pattern which looks like the daily commute! The number of cyclists going west is much higher in the morning than in the late afternoon. The opposite is true for the number of cyclists going east. <br><br>
Apparently, people live to the East of the bridge, and work to the West of the bridge!
Step6:  We now create a new table to plot some different things.
Step7:  This last plot is shows a bit more information. The plot is a graph for every day over the past couple of years - number of cyclists per hour of every day. It again shows the 2 peaks - one in the morning and one in the late afternoon. Obviously, this represents the daily commute. <br><br>
However, in between the peaks, we can see a wave occuring in the middle of the day. This is probably the people that are going out for a bike ride in the middle of the day during the weekends!
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('seaborn')
Explanation: First we import some libraries. Libraries (such as matplotlib, os, pandas, urllib) allow you to do more things than with Python's base functionality. They contain functions that have specific purposes. Some libraries contain functions that allow you to calculate the minimum, maximum, mean, standard deviation and so on. Other libraries are focused on making graphs and stuff to allow you present your findings in a quick and clean way.  <br> <br>
In the following, we use: <br>
Matplotlib allows you to make plots and graphs <br>
Pandas is the Python library which contains a lot of data analysis functionality <br>
urllib is a python library that contains functions which allow you to pull data from websites
End of explanation
import os
import pandas as pd
from urllib.request import urlretrieve
URL = 'https://data.seattle.gov/api/views/65db-xm6k/rows.csv?accessType=DOWNLOAD'
def get_fremont_data(filename = 'Fremont.csv', url=URL, force_download = False):
    if force_download or not os.path.exists(filename):
        urlretrieve(url, filename)
        
    data = pd.read_csv('Fremont.csv', index_col='Date', parse_dates=True)
    data.columns = ['Cyclists Westwards', 'Cyclists Eastwards']
    data['Total'] = data['Cyclists Westwards'] + data['Cyclists Eastwards']
    
    return data
Explanation: In the section below, we first import some libraries we will use. Next, we define a variable called URL, this is a webadress to our data set. The dataset contains the number of cyclists passing over the Fremont Bridge in Seattle in both directions every hour, since 2012 (I think). <br><br>
We then define a function (remember, a function is a bunch of code that does 1 specific thing) which imports the data set from the given URL, called get_fremont_data. The function stores the data set in "data" and then spits out the data set so we can use it!
End of explanation
data = get_fremont_data()
data
Explanation: Important to note is that if we make a function which does a thing, it doesnt do that thing untill you actually call the function, calling a function is easy: just type its name and assign the function output to a variable name (which we creatively call data here. <br><br>
If we would call the function without assigning it to a variable name, it will still spit out the table you see below, we just would not be able to do anything with the table, as it has no name we can call.
End of explanation
data.resample('W').sum().plot();
Explanation: So great! We have not imported our dataset and we know it exists because we can show it. To find out what is actually interesting about the cyclists, we can plot the weekly sum of cyclists in both directions, as well as the total number of cyclists. <br><br>
Interesting to see is the wave pattern (sinusoid) to the amount of cyclists on a yearly basis. Apparently, there are a lot fewer people who take the bycicle in the winter than there are in the summer. This isnt that surprising.
End of explanation
ax = data.resample('D').sum().rolling(365).sum().plot();
ax.set_ylim(0,None)
Explanation: The graph below is boring, just skip it
End of explanation
data.groupby(data.index.time).mean().plot();
Explanation: The graph below shows an interesting pattern which looks like the daily commute! The number of cyclists going west is much higher in the morning than in the late afternoon. The opposite is true for the number of cyclists going east. <br><br>
Apparently, people live to the East of the bridge, and work to the West of the bridge!
End of explanation
pivoted = data.pivot_table('Total', index=data.index.time, columns = data.index.date)
pivoted.iloc[:5, :5]
Explanation: We now create a new table to plot some different things.
End of explanation
pivoted.plot(legend=False, alpha = 0.02);
Explanation: This last plot is shows a bit more information. The plot is a graph for every day over the past couple of years - number of cyclists per hour of every day. It again shows the 2 peaks - one in the morning and one in the late afternoon. Obviously, this represents the daily commute. <br><br>
However, in between the peaks, we can see a wave occuring in the middle of the day. This is probably the people that are going out for a bike ride in the middle of the day during the weekends!
End of explanation
<END_TASK>