<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 takin' care of imports
Step1:  read in data
Step2:  repeat data fixing from previous exercise
Step3:  1a. Plot the daily temperature over the course of the year. (This should probably be a line chart.)
Step4:  1b. Create a bar chart that shows the average temperature and humidity by month.
Step5:  2. Use a scatterplot to show how the daily rental volume varies with temperature. Use a different series (with different colors) for each season.
Step6:  3. Create another scatterplot to show how daily rental volume varies with windspeed.  As above, use a different series for each season.
Step7:  4. How do the rental volumes vary with geography? Compute the average daily rentals for each station and use this as the radius for a scatterplot of each station's latitude and longitude.
pull out just the station_start column from 'usage' file data, turn it into a new dataframe 'usage_stations'
Step8:  pull out the lat and long from 'stations' file data, turn it into a new dataframe 'stations_geo'
set the index of 'stations_geo' to be the values of the 'stations' column from the same 'stations' file data; this is important because we want both of our dataframes to have similar indices
Step9:  make a new dataframe 'station_count' that sums the occurrences of each station name in 'usage_stations'
Step10:  create a new colum 'rides' in 'stations_geo' which is populated with the data from 'station_count'
Step11:  get rid of all thye 'NaN' rows, then plot the data on a scatterplot where the radius of each point is the total number of rides at that location divided by the 366 days of the year
<ASSISTANT_TASK:>
Python Code:
from pandas import Series, DataFrame
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
Explanation: takin' care of imports
End of explanation
weather = pd.read_table('data/daily_weather.tsv')
stations = pd.read_table('data/stations.tsv')
usage = pd.read_table('data/usage_2012.tsv')
Explanation: read in data
End of explanation
weather['date'] = pd.to_datetime(weather['date'])
weather.loc[weather['season_code'] == 1, 'season_desc'] = 'winter'
weather.loc[weather['season_code'] == 2, 'season_desc'] = 'spring'
weather.loc[weather['season_code'] == 3, 'season_desc'] = 'summer'
weather.loc[weather['season_code'] == 4, 'season_desc'] = 'fall'
weather.loc[weather['season_desc'] == 'winter', 'season_code'] = 4
weather.loc[weather['season_desc'] == 'spring', 'season_code'] = 1
weather.loc[weather['season_desc'] == 'summer', 'season_code'] = 2
weather.loc[weather['season_desc'] == 'fall', 'season_code'] = 3
Explanation: repeat data fixing from previous exercise
End of explanation
weather.plot(x='date', y='temp')
plt.show()
Explanation: 1a. Plot the daily temperature over the course of the year. (This should probably be a line chart.)
End of explanation
temp_humid = weather[['temp', 'humidity']].groupby(weather['date'].dt.month).mean()
temp_humid.plot(kind='bar', width=0.75, color=['#EE4444','#4444EE'])
plt.show()
Explanation: 1b. Create a bar chart that shows the average temperature and humidity by month.
End of explanation
spring_daily_vol = weather.loc[weather['season_desc'] == 'spring']
summer_daily_vol = weather.loc[weather['season_desc'] == 'summer']
fall_daily_vol = weather.loc[weather['season_desc'] == 'fall']
winter_daily_vol = weather.loc[weather['season_desc'] == 'winter']
spr_ax = spring_daily_vol.plot(kind='scatter', x='temp', y='total_riders', c='yellow', s=50, alpha=.4)
sum_ax = summer_daily_vol.plot(kind='scatter', x='temp', y='total_riders', c='lightgreen', s=50, alpha=.4, ax=spr_ax)
fal_ax = fall_daily_vol.plot(kind='scatter', x='temp', y='total_riders', c='#ee5555', s=50, alpha=.4, ax=sum_ax)
win_ax = winter_daily_vol.plot(kind='scatter', x='temp', y='total_riders', c='lightblue', s=50, alpha=.4, ax=fal_ax)
plt.title('Temp vs Daily Rental Volume')
plt.show()
Explanation: 2. Use a scatterplot to show how the daily rental volume varies with temperature. Use a different series (with different colors) for each season.
End of explanation
spr_ax = spring_daily_vol.plot(kind='scatter', x='windspeed', y='total_riders', c='yellow', s=50, alpha=.4)
sum_ax = summer_daily_vol.plot(kind='scatter', x='windspeed', y='total_riders', c='lightgreen', s=50, alpha=.4, ax=spr_ax)
fal_ax = fall_daily_vol.plot(kind='scatter', x='windspeed', y='total_riders', c='#ee5555', s=50, alpha=.4, ax=sum_ax)
win_ax = winter_daily_vol.plot(kind='scatter', x='windspeed', y='total_riders', c='lightblue', s=50, alpha=.4, ax=fal_ax)
plt.title('Windspeed vs Daily Rental Volume')
plt.show()
Explanation: 3. Create another scatterplot to show how daily rental volume varies with windspeed.  As above, use a different series for each season.
End of explanation
usage_stations = usage[['station_start']]
usage_stations.head()
Explanation: 4. How do the rental volumes vary with geography? Compute the average daily rentals for each station and use this as the radius for a scatterplot of each station's latitude and longitude.
pull out just the station_start column from 'usage' file data, turn it into a new dataframe 'usage_stations'
End of explanation
stations_geo = DataFrame({'lat': stations.lat, 'long': stations.long})
stations_geo.index = stations.station.values
stations_geo.head()
Explanation: pull out the lat and long from 'stations' file data, turn it into a new dataframe 'stations_geo'
set the index of 'stations_geo' to be the values of the 'stations' column from the same 'stations' file data; this is important because we want both of our dataframes to have similar indices
End of explanation
station_count = DataFrame(usage_stations['station_start'].value_counts())
station_count.head()
Explanation: make a new dataframe 'station_count' that sums the occurrences of each station name in 'usage_stations'
End of explanation
stations_geo['rides'] = station_count
stations_geo.head()
Explanation: create a new colum 'rides' in 'stations_geo' which is populated with the data from 'station_count'
End of explanation
cleared = stations_geo.dropna()
cleared.head()
cleared.plot(kind='scatter', x='long', y='lat', s=(cleared['rides'] / 366) * 5, alpha=0.6, figsize=(10, 10))
plt.show()
Explanation: get rid of all thye 'NaN' rows, then plot the data on a scatterplot where the radius of each point is the total number of rides at that location divided by the 366 days of the year
End of explanation
<END_TASK>