Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mengyuz/d16b5a64d775c449b204 to your computer and use it in GitHub Desktop.
Save Mengyuz/d16b5a64d775c449b204 to your computer and use it in GitHub Desktop.
from pandas import *
from ggplot import *
def plot_weather_data(turnstile_weather):
'''
You are passed in a dataframe called turnstile_weather.
Use turnstile_weather along with ggplot to make a data visualization
focused on the MTA and weather data we used in assignment #3.
You should feel free to implement something that we discussed in class
(e.g., scatterplots, line plots, or histograms) or attempt to implement
something more advanced if you'd like.
Here are some suggestions for things to investigate and illustrate:
* Ridership by time of day or day of week
* How ridership varies based on Subway station (UNIT)
* Which stations have more exits or entries at different times of day
(You can use UNIT as a proxy for subway station.)
If you'd like to learn more about ggplot and its capabilities, take
a look at the documentation at:
https://pypi.python.org/pypi/ggplot/
You can check out:
https://www.dropbox.com/s/meyki2wl9xfa7yk/turnstile_data_master_with_weather.csv
To see all the columns and data points included in the turnstile_weather
dataframe.
However, due to the limitation of our Amazon EC2 server, we are giving you a random
subset, about 1/3 of the actual data in the turnstile_weather dataframe.
'''
plot = ggplot(turnstile_weather, aes('ENTRIESn_hourly', fill='rain')) + geom_bar(binwidth=50) + xlim(low=0, high=5000) + \
xlab("Hourly Entries - Bins of Size 50") + \
ylab("Hourly Entries - Count in each bin") + \
ggtitle("Hourly Entries Histogram based on weather")
return plot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment