In [1]:
import pandas as pd
import numpy as np
from pandas import Series, DataFrame
In [2]:
weather = pd.read_table('daily_weather.tsv')
In [3]:
weather.groupby('season_desc').agg({'temp': np.mean})
Out[3]:
In [4]:
fix = weather.replace("Fall", "Summer_").replace("Summer", "Spring_").replace("Winter", "Fall_").replace("Spring", "Winter_")
In [6]:
weather.groupby('season_desc').agg({'temp': np.mean})
Out[6]:
In [9]:
weather['months'] = pd.DatetimeIndex(weather.date).month
In [10]:
weather.groupby('months').agg({'total_riders': np.sum})
Out[10]:
weather[['total_riders', 'temp']].corr()
3.Investigate how the number of rentals varies with temperature. Is this trend constant across seasons? Across months?
In [11]:
weather[['total_riders', 'temp', 'months']].groupby('months').corr()
Out[11]:
weather[['total_riders', 'temp', 'season_desc']].groupby('season_desc').corr()
In [12]:
weather[['no_casual_riders', 'no_reg_riders', 'temp']].corr()
Out[12]:
4.There are various types of users in the usage data sets. What sorts of things can you say about how they use the bikes differently?
In [13]:
weather[['no_casual_riders', 'no_reg_riders']].corr()
Out[13]:
In [16]:
weather[['is_holiday', 'total_riders']].sum()
Out[16]:
In [15]:
weather[['is_holiday', 'total_riders']].corr()
Out[15]:
In [ ]:
In [ ]: