Process Bike-Share data with Pandas


In [1]:
import pandas as pd

In [2]:
import numpy as np

In [3]:
weather = pd.read_table("daily_weather.tsv")

In [4]:
usage = pd.read_table("usage_2012.tsv")

In [5]:
station = pd.read_table("stations.tsv")

Question 1: Compute the average temperature by season ('season_desc'). Figure out what's wrong with the original data and fix it.


In [6]:
weather


Out[6]:
date weekday season_code season_desc is_holiday is_work_day weather_code weather_desc temp subjective_temp humidity windspeed no_casual_riders no_reg_riders total_riders
0 2012-01-01 0 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.370000 0.375621 0.692500 0.192167 686 1608 2294
1 2012-01-02 1 1 Spring 1 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.273043 0.252304 0.381304 0.329665 244 1707 1951
2 2012-01-03 2 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.150000 0.126275 0.441250 0.365671 89 2147 2236
3 2012-01-04 3 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.107500 0.119337 0.414583 0.184700 95 2273 2368
4 2012-01-05 4 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.265833 0.278412 0.524167 0.129987 140 3132 3272
5 2012-01-06 5 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.334167 0.340267 0.542083 0.167908 307 3791 4098
6 2012-01-07 6 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.393333 0.390779 0.531667 0.174758 1070 3451 4521
7 2012-01-08 0 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.337500 0.340258 0.465000 0.191542 599 2826 3425
8 2012-01-09 1 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.224167 0.247479 0.701667 0.098900 106 2270 2376
9 2012-01-10 2 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.308696 0.318826 0.646522 0.187552 173 3425 3598
10 2012-01-11 3 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.274167 0.282821 0.847500 0.131221 92 2085 2177
11 2012-01-12 4 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.382500 0.381938 0.802917 0.180967 269 3828 4097
12 2012-01-13 5 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.274167 0.249362 0.507500 0.378108 174 3040 3214
13 2012-01-14 6 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.180000 0.183087 0.457500 0.187183 333 2160 2493
14 2012-01-15 0 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.166667 0.161625 0.419167 0.251258 284 2027 2311
15 2012-01-16 1 1 Spring 1 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.190000 0.190663 0.522500 0.231358 217 2081 2298
16 2012-01-17 2 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.373043 0.364278 0.716087 0.349130 127 2808 2935
17 2012-01-18 3 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.303333 0.275254 0.443333 0.415429 109 3267 3376
18 2012-01-19 4 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.190000 0.190038 0.497500 0.220158 130 3162 3292
19 2012-01-20 5 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.217500 0.220958 0.450000 0.202750 115 3048 3163
20 2012-01-21 6 1 Spring 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.173333 0.174875 0.831250 0.222642 67 1234 1301
21 2012-01-22 0 1 Spring 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.162500 0.162250 0.796250 0.199638 196 1781 1977
22 2012-01-23 1 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.218333 0.243058 0.911250 0.110708 145 2287 2432
23 2012-01-24 2 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.342500 0.349108 0.835833 0.123767 439 3900 4339
24 2012-01-25 3 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.294167 0.294821 0.643750 0.161071 467 3803 4270
25 2012-01-26 4 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.341667 0.356050 0.769583 0.073396 244 3831 4075
26 2012-01-27 5 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.425000 0.415383 0.741250 0.342667 269 3187 3456
27 2012-01-28 6 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.315833 0.326379 0.543333 0.210829 775 3248 4023
28 2012-01-29 0 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.282500 0.272721 0.311250 0.240050 558 2685 3243
29 2012-01-30 1 1 Spring 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.269167 0.262625 0.400833 0.215792 126 3498 3624
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
336 2012-12-02 0 4 Winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.347500 0.359208 0.823333 0.124379 892 3757 4649
337 2012-12-03 1 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.452500 0.455796 0.767500 0.082721 555 5679 6234
338 2012-12-04 2 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.475833 0.469054 0.733750 0.174129 551 6055 6606
339 2012-12-05 3 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.438333 0.428012 0.485000 0.324021 331 5398 5729
340 2012-12-06 4 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.255833 0.258204 0.508750 0.174754 340 5035 5375
341 2012-12-07 5 4 Winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.320833 0.321958 0.764167 0.130600 349 4659 5008
342 2012-12-08 6 4 Winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.381667 0.389508 0.911250 0.101379 1153 4429 5582
343 2012-12-09 0 4 Winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.384167 0.390146 0.905417 0.157975 441 2787 3228
344 2012-12-10 1 4 Winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.435833 0.435575 0.925000 0.190308 329 4841 5170
345 2012-12-11 2 4 Winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.353333 0.338363 0.596667 0.296037 282 5219 5501
346 2012-12-12 3 4 Winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.297500 0.297338 0.538333 0.162937 310 5009 5319
347 2012-12-13 4 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.295833 0.294188 0.485833 0.174129 425 5107 5532
348 2012-12-14 5 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.281667 0.294192 0.642917 0.131229 429 5182 5611
349 2012-12-15 6 4 Winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.324167 0.338383 0.650417 0.106350 767 4280 5047
350 2012-12-16 0 4 Winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.362500 0.369938 0.838750 0.100742 538 3248 3786
351 2012-12-17 1 4 Winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.393333 0.401500 0.907083 0.098258 212 4373 4585
352 2012-12-18 2 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.410833 0.409708 0.666250 0.221404 433 5124 5557
353 2012-12-19 3 4 Winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.332500 0.342162 0.625417 0.184092 333 4934 5267
354 2012-12-20 4 4 Winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.330000 0.335217 0.667917 0.132463 314 3814 4128
355 2012-12-21 5 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.326667 0.301767 0.556667 0.374383 221 3402 3623
356 2012-12-22 6 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.265833 0.236113 0.441250 0.407346 205 1544 1749
357 2012-12-23 0 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.245833 0.259471 0.515417 0.133083 408 1379 1787
358 2012-12-24 1 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.231304 0.258900 0.791304 0.077230 174 746 920
359 2012-12-25 2 1 Spring 1 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.291304 0.294465 0.734783 0.168726 440 573 1013
360 2012-12-26 3 1 Spring 0 1 3 Light Snow, Light Rain + Thunderstorm + Scatte... 0.243333 0.220333 0.823333 0.316546 9 432 441
361 2012-12-27 4 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.254167 0.226642 0.652917 0.350133 247 1867 2114
362 2012-12-28 5 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.253333 0.255046 0.590000 0.155471 644 2451 3095
363 2012-12-29 6 1 Spring 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.253333 0.242400 0.752917 0.124383 159 1182 1341
364 2012-12-30 0 1 Spring 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.255833 0.231700 0.483333 0.350754 364 1432 1796
365 2012-12-31 1 1 Spring 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.215833 0.223487 0.577500 0.154846 439 2290 2729

366 rows × 15 columns


In [7]:
mean = weather.groupby('season_desc')['temp'].mean()

In [68]:
mean


Out[68]:
season_desc
Fall      0.711445
Spring    0.321700
Summer    0.554557
Winter    0.419368
Name: temp, dtype: float64

In [8]:
weather.loc[weather['season_code'] == 1, 'season_desc'] = 'winter'

In [9]:
weather.loc[weather['season_code'] == 2, 'season_desc'] = 'spring'

In [10]:
weather.loc[weather['season_code'] == 3, 'season_desc'] = 'summer'

In [11]:
weather.loc[weather['season_code'] == 4, 'season_desc'] = 'fall'

In [12]:
weather


Out[12]:
date weekday season_code season_desc is_holiday is_work_day weather_code weather_desc temp subjective_temp humidity windspeed no_casual_riders no_reg_riders total_riders
0 2012-01-01 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.370000 0.375621 0.692500 0.192167 686 1608 2294
1 2012-01-02 1 1 winter 1 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.273043 0.252304 0.381304 0.329665 244 1707 1951
2 2012-01-03 2 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.150000 0.126275 0.441250 0.365671 89 2147 2236
3 2012-01-04 3 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.107500 0.119337 0.414583 0.184700 95 2273 2368
4 2012-01-05 4 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.265833 0.278412 0.524167 0.129987 140 3132 3272
5 2012-01-06 5 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.334167 0.340267 0.542083 0.167908 307 3791 4098
6 2012-01-07 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.393333 0.390779 0.531667 0.174758 1070 3451 4521
7 2012-01-08 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.337500 0.340258 0.465000 0.191542 599 2826 3425
8 2012-01-09 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.224167 0.247479 0.701667 0.098900 106 2270 2376
9 2012-01-10 2 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.308696 0.318826 0.646522 0.187552 173 3425 3598
10 2012-01-11 3 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.274167 0.282821 0.847500 0.131221 92 2085 2177
11 2012-01-12 4 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.382500 0.381938 0.802917 0.180967 269 3828 4097
12 2012-01-13 5 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.274167 0.249362 0.507500 0.378108 174 3040 3214
13 2012-01-14 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.180000 0.183087 0.457500 0.187183 333 2160 2493
14 2012-01-15 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.166667 0.161625 0.419167 0.251258 284 2027 2311
15 2012-01-16 1 1 winter 1 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.190000 0.190663 0.522500 0.231358 217 2081 2298
16 2012-01-17 2 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.373043 0.364278 0.716087 0.349130 127 2808 2935
17 2012-01-18 3 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.303333 0.275254 0.443333 0.415429 109 3267 3376
18 2012-01-19 4 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.190000 0.190038 0.497500 0.220158 130 3162 3292
19 2012-01-20 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.217500 0.220958 0.450000 0.202750 115 3048 3163
20 2012-01-21 6 1 winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.173333 0.174875 0.831250 0.222642 67 1234 1301
21 2012-01-22 0 1 winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.162500 0.162250 0.796250 0.199638 196 1781 1977
22 2012-01-23 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.218333 0.243058 0.911250 0.110708 145 2287 2432
23 2012-01-24 2 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.342500 0.349108 0.835833 0.123767 439 3900 4339
24 2012-01-25 3 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.294167 0.294821 0.643750 0.161071 467 3803 4270
25 2012-01-26 4 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.341667 0.356050 0.769583 0.073396 244 3831 4075
26 2012-01-27 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.425000 0.415383 0.741250 0.342667 269 3187 3456
27 2012-01-28 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.315833 0.326379 0.543333 0.210829 775 3248 4023
28 2012-01-29 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.282500 0.272721 0.311250 0.240050 558 2685 3243
29 2012-01-30 1 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.269167 0.262625 0.400833 0.215792 126 3498 3624
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
336 2012-12-02 0 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.347500 0.359208 0.823333 0.124379 892 3757 4649
337 2012-12-03 1 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.452500 0.455796 0.767500 0.082721 555 5679 6234
338 2012-12-04 2 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.475833 0.469054 0.733750 0.174129 551 6055 6606
339 2012-12-05 3 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.438333 0.428012 0.485000 0.324021 331 5398 5729
340 2012-12-06 4 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.255833 0.258204 0.508750 0.174754 340 5035 5375
341 2012-12-07 5 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.320833 0.321958 0.764167 0.130600 349 4659 5008
342 2012-12-08 6 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.381667 0.389508 0.911250 0.101379 1153 4429 5582
343 2012-12-09 0 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.384167 0.390146 0.905417 0.157975 441 2787 3228
344 2012-12-10 1 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.435833 0.435575 0.925000 0.190308 329 4841 5170
345 2012-12-11 2 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.353333 0.338363 0.596667 0.296037 282 5219 5501
346 2012-12-12 3 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.297500 0.297338 0.538333 0.162937 310 5009 5319
347 2012-12-13 4 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.295833 0.294188 0.485833 0.174129 425 5107 5532
348 2012-12-14 5 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.281667 0.294192 0.642917 0.131229 429 5182 5611
349 2012-12-15 6 4 fall 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.324167 0.338383 0.650417 0.106350 767 4280 5047
350 2012-12-16 0 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.362500 0.369938 0.838750 0.100742 538 3248 3786
351 2012-12-17 1 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.393333 0.401500 0.907083 0.098258 212 4373 4585
352 2012-12-18 2 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.410833 0.409708 0.666250 0.221404 433 5124 5557
353 2012-12-19 3 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.332500 0.342162 0.625417 0.184092 333 4934 5267
354 2012-12-20 4 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.330000 0.335217 0.667917 0.132463 314 3814 4128
355 2012-12-21 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.326667 0.301767 0.556667 0.374383 221 3402 3623
356 2012-12-22 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.265833 0.236113 0.441250 0.407346 205 1544 1749
357 2012-12-23 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.245833 0.259471 0.515417 0.133083 408 1379 1787
358 2012-12-24 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.231304 0.258900 0.791304 0.077230 174 746 920
359 2012-12-25 2 1 winter 1 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.291304 0.294465 0.734783 0.168726 440 573 1013
360 2012-12-26 3 1 winter 0 1 3 Light Snow, Light Rain + Thunderstorm + Scatte... 0.243333 0.220333 0.823333 0.316546 9 432 441
361 2012-12-27 4 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.254167 0.226642 0.652917 0.350133 247 1867 2114
362 2012-12-28 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.253333 0.255046 0.590000 0.155471 644 2451 3095
363 2012-12-29 6 1 winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.253333 0.242400 0.752917 0.124383 159 1182 1341
364 2012-12-30 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.255833 0.231700 0.483333 0.350754 364 1432 1796
365 2012-12-31 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.215833 0.223487 0.577500 0.154846 439 2290 2729

366 rows × 15 columns

Question 2: Various of the columns represent dates or datetimes, but out of the box pd.read_table won't treat them correctly. This makes it hard to (for example) compute the number of rentals by month. Fix the dates and compute the number of rentals by month.


In [13]:
weather['date'] = pd.to_datetime(weather['date'])

In [14]:
type(weather['date'][1])


Out[14]:
pandas.tslib.Timestamp

In [16]:
month_rental = weather.groupby(weather['date'].dt.month)['total_riders'].sum()

In [17]:
month_rental


Out[17]:
1      96744
2     103137
3     164875
4     174224
5     195865
6     202830
7     203607
8     214503
9     218573
10    198841
11    152664
12    123713
Name: total_riders, dtype: int64

Question 3: Investigate how the number of rentals varies with temperature. Is this trend constant across seasons? Across months?


In [18]:
weather


Out[18]:
date weekday season_code season_desc is_holiday is_work_day weather_code weather_desc temp subjective_temp humidity windspeed no_casual_riders no_reg_riders total_riders
0 2012-01-01 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.370000 0.375621 0.692500 0.192167 686 1608 2294
1 2012-01-02 1 1 winter 1 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.273043 0.252304 0.381304 0.329665 244 1707 1951
2 2012-01-03 2 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.150000 0.126275 0.441250 0.365671 89 2147 2236
3 2012-01-04 3 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.107500 0.119337 0.414583 0.184700 95 2273 2368
4 2012-01-05 4 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.265833 0.278412 0.524167 0.129987 140 3132 3272
5 2012-01-06 5 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.334167 0.340267 0.542083 0.167908 307 3791 4098
6 2012-01-07 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.393333 0.390779 0.531667 0.174758 1070 3451 4521
7 2012-01-08 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.337500 0.340258 0.465000 0.191542 599 2826 3425
8 2012-01-09 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.224167 0.247479 0.701667 0.098900 106 2270 2376
9 2012-01-10 2 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.308696 0.318826 0.646522 0.187552 173 3425 3598
10 2012-01-11 3 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.274167 0.282821 0.847500 0.131221 92 2085 2177
11 2012-01-12 4 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.382500 0.381938 0.802917 0.180967 269 3828 4097
12 2012-01-13 5 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.274167 0.249362 0.507500 0.378108 174 3040 3214
13 2012-01-14 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.180000 0.183087 0.457500 0.187183 333 2160 2493
14 2012-01-15 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.166667 0.161625 0.419167 0.251258 284 2027 2311
15 2012-01-16 1 1 winter 1 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.190000 0.190663 0.522500 0.231358 217 2081 2298
16 2012-01-17 2 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.373043 0.364278 0.716087 0.349130 127 2808 2935
17 2012-01-18 3 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.303333 0.275254 0.443333 0.415429 109 3267 3376
18 2012-01-19 4 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.190000 0.190038 0.497500 0.220158 130 3162 3292
19 2012-01-20 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.217500 0.220958 0.450000 0.202750 115 3048 3163
20 2012-01-21 6 1 winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.173333 0.174875 0.831250 0.222642 67 1234 1301
21 2012-01-22 0 1 winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.162500 0.162250 0.796250 0.199638 196 1781 1977
22 2012-01-23 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.218333 0.243058 0.911250 0.110708 145 2287 2432
23 2012-01-24 2 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.342500 0.349108 0.835833 0.123767 439 3900 4339
24 2012-01-25 3 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.294167 0.294821 0.643750 0.161071 467 3803 4270
25 2012-01-26 4 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.341667 0.356050 0.769583 0.073396 244 3831 4075
26 2012-01-27 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.425000 0.415383 0.741250 0.342667 269 3187 3456
27 2012-01-28 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.315833 0.326379 0.543333 0.210829 775 3248 4023
28 2012-01-29 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.282500 0.272721 0.311250 0.240050 558 2685 3243
29 2012-01-30 1 1 winter 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.269167 0.262625 0.400833 0.215792 126 3498 3624
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
336 2012-12-02 0 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.347500 0.359208 0.823333 0.124379 892 3757 4649
337 2012-12-03 1 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.452500 0.455796 0.767500 0.082721 555 5679 6234
338 2012-12-04 2 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.475833 0.469054 0.733750 0.174129 551 6055 6606
339 2012-12-05 3 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.438333 0.428012 0.485000 0.324021 331 5398 5729
340 2012-12-06 4 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.255833 0.258204 0.508750 0.174754 340 5035 5375
341 2012-12-07 5 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.320833 0.321958 0.764167 0.130600 349 4659 5008
342 2012-12-08 6 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.381667 0.389508 0.911250 0.101379 1153 4429 5582
343 2012-12-09 0 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.384167 0.390146 0.905417 0.157975 441 2787 3228
344 2012-12-10 1 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.435833 0.435575 0.925000 0.190308 329 4841 5170
345 2012-12-11 2 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.353333 0.338363 0.596667 0.296037 282 5219 5501
346 2012-12-12 3 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.297500 0.297338 0.538333 0.162937 310 5009 5319
347 2012-12-13 4 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.295833 0.294188 0.485833 0.174129 425 5107 5532
348 2012-12-14 5 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.281667 0.294192 0.642917 0.131229 429 5182 5611
349 2012-12-15 6 4 fall 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.324167 0.338383 0.650417 0.106350 767 4280 5047
350 2012-12-16 0 4 fall 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.362500 0.369938 0.838750 0.100742 538 3248 3786
351 2012-12-17 1 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.393333 0.401500 0.907083 0.098258 212 4373 4585
352 2012-12-18 2 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.410833 0.409708 0.666250 0.221404 433 5124 5557
353 2012-12-19 3 4 fall 0 1 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.332500 0.342162 0.625417 0.184092 333 4934 5267
354 2012-12-20 4 4 fall 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.330000 0.335217 0.667917 0.132463 314 3814 4128
355 2012-12-21 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.326667 0.301767 0.556667 0.374383 221 3402 3623
356 2012-12-22 6 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.265833 0.236113 0.441250 0.407346 205 1544 1749
357 2012-12-23 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.245833 0.259471 0.515417 0.133083 408 1379 1787
358 2012-12-24 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.231304 0.258900 0.791304 0.077230 174 746 920
359 2012-12-25 2 1 winter 1 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.291304 0.294465 0.734783 0.168726 440 573 1013
360 2012-12-26 3 1 winter 0 1 3 Light Snow, Light Rain + Thunderstorm + Scatte... 0.243333 0.220333 0.823333 0.316546 9 432 441
361 2012-12-27 4 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.254167 0.226642 0.652917 0.350133 247 1867 2114
362 2012-12-28 5 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.253333 0.255046 0.590000 0.155471 644 2451 3095
363 2012-12-29 6 1 winter 0 0 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.253333 0.242400 0.752917 0.124383 159 1182 1341
364 2012-12-30 0 1 winter 0 0 1 Clear, Few clouds, Partly cloudy, Partly cloudy 0.255833 0.231700 0.483333 0.350754 364 1432 1796
365 2012-12-31 1 1 winter 0 1 2 Mist + Cloudy, Mist + Broken clouds, Mist + Fe... 0.215833 0.223487 0.577500 0.154846 439 2290 2729

366 rows × 15 columns


In [36]:
mean


Out[36]:
season_desc
fall      0.419368
spring    0.554557
summer    0.711445
winter    0.321700
Name: temp, dtype: float64

In [37]:
month_rental


Out[37]:
1      96744
2     103137
3     164875
4     174224
5     195865
6     202830
7     203607
8     214503
9     218573
10    198841
11    152664
12    123713
Name: total_riders, dtype: int64

In [19]:
weather[['temp', 'total_riders']].corr()


Out[19]:
temp total_riders
temp 1.000000 0.713793
total_riders 0.713793 1.000000

In [20]:
weather['month'] = pd.DatetimeIndex(weather.date).month

In [21]:
weather[['month', 'temp', 'total_riders']].corr()


Out[21]:
month temp total_riders
month 1.000000 0.147795 0.266502
temp 0.147795 1.000000 0.713793
total_riders 0.266502 0.713793 1.000000

In [22]:
weather[['total_riders', 'temp', 'month']].groupby('month').corr()


Out[22]:
temp total_riders
month
1 temp 1.000000 0.689495
total_riders 0.689495 1.000000
2 temp 1.000000 0.716206
total_riders 0.716206 1.000000
3 temp 1.000000 0.735575
total_riders 0.735575 1.000000
4 temp 1.000000 0.533387
total_riders 0.533387 1.000000
5 temp 1.000000 0.065599
total_riders 0.065599 1.000000
6 temp 1.000000 -0.330884
total_riders -0.330884 1.000000
7 temp 1.000000 -0.184704
total_riders -0.184704 1.000000
8 temp 1.000000 0.288264
total_riders 0.288264 1.000000
9 temp 1.000000 -0.418753
total_riders -0.418753 1.000000
10 temp 1.000000 0.466666
total_riders 0.466666 1.000000
11 temp 1.000000 0.511232
total_riders 0.511232 1.000000
12 temp 1.000000 0.690062
total_riders 0.690062 1.000000

The positive correlation is consistent throughout months.


In [23]:
weather[['total_riders', 'temp', 'season_desc']].groupby('season_desc').corr()


Out[23]:
temp total_riders
season_desc
fall temp 1.000000 0.626532
total_riders 0.626532 1.000000
spring temp 1.000000 0.415687
total_riders 0.415687 1.000000
summer temp 1.000000 -0.325743
total_riders -0.325743 1.000000
winter temp 1.000000 0.811410
total_riders 0.811410 1.000000

And this is consistent throughout seasons as well.

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 [24]:
usage


Out[24]:
bike_id time_start time_end duration_mins station_start station_end cust_type
0 W01412 2012-01-01 00:04:00 2012-01-01 00:11:00 7 7th & R St NW / Shaw Library 7th & T St NW Registered
1 W00524 2012-01-01 00:10:00 2012-01-01 00:29:00 19 Georgia & New Hampshire Ave NW 16th & Harvard St NW Casual
2 W00235 2012-01-01 00:10:00 2012-01-01 00:29:00 19 Georgia & New Hampshire Ave NW 16th & Harvard St NW Registered
3 W00864 2012-01-01 00:15:00 2012-01-01 00:23:00 8 14th & V St NW Park Rd & Holmead Pl NW Registered
4 W00995 2012-01-01 00:15:00 2012-01-01 00:23:00 8 11th & Kenyon St NW 7th & T St NW Registered
5 W00466 2012-01-01 00:17:00 2012-01-01 00:23:00 6 Court House Metro / 15th & N Uhle St Lynn & 19th St North Registered
6 W00525 2012-01-01 00:18:00 2012-01-01 00:47:00 29 37th & O St NW / Georgetown University 9th & Upshur St NW Registered
7 W00340 2012-01-01 00:22:00 2012-01-01 00:27:00 5 14th & V St NW 15th & P St NW Registered
8 W00466 2012-01-01 00:24:00 2012-01-01 00:33:00 9 Lynn & 19th St North 25th St & Pennsylvania Ave NW Registered
9 W00963 2012-01-01 00:25:00 2012-01-01 00:40:00 15 14th & V St NW L'Enfant Plaza / 7th & C St SW Registered
10 W01398 2012-01-01 00:29:00 2012-01-01 00:48:00 19 Tenleytown / Wisconsin Ave & Albemarle St NW Massachusetts Ave & Dupont Circle NW Registered
11 W00042 2012-01-01 00:30:00 2012-01-01 00:38:00 8 New York Ave & 15th St NW 21st & I St NW Registered
12 W00570 2012-01-01 00:32:00 2012-01-01 00:50:00 18 Metro Center / 12th & G St NW Massachusetts Ave & Dupont Circle NW Registered
13 W01463 2012-01-01 00:32:00 2012-01-01 00:50:00 18 Lamont & Mt Pleasant NW 14th & Rhode Island Ave NW Registered
14 W00535 2012-01-01 00:33:00 2012-01-01 00:50:00 17 Lamont & Mt Pleasant NW 14th & Rhode Island Ave NW Registered
15 W00494 2012-01-01 00:33:00 2012-01-01 00:50:00 17 Metro Center / 12th & G St NW Massachusetts Ave & Dupont Circle NW Registered
16 W00466 2012-01-01 00:33:00 2012-01-01 00:41:00 8 25th St & Pennsylvania Ave NW New York Ave & 15th St NW Registered
17 W00663 2012-01-01 00:33:00 2012-01-01 00:39:00 6 7th & T St NW Convention Center / 7th & M St NW Registered
18 W01052 2012-01-01 00:34:00 2012-01-01 00:42:00 8 14th & Rhode Island Ave NW 14th & V St NW Registered
19 W00174 2012-01-01 00:36:00 2012-01-01 00:52:00 16 17th & Corcoran St NW 17th & Corcoran St NW Registered
20 W01298 2012-01-01 00:37:00 2012-01-01 00:41:00 4 17th & Corcoran St NW Massachusetts Ave & Dupont Circle NW Registered
21 W01333 2012-01-01 00:39:00 2012-01-01 00:44:00 5 NaN 8th & H St NW Registered
22 W00697 2012-01-01 00:39:00 2012-01-01 00:42:00 3 Potomac & Pennsylvania Ave SE Potomac & Pennsylvania Ave SE Registered
23 W00260 2012-01-01 00:41:00 2012-01-01 00:49:00 8 4th & E St SW 5th & F St NW Registered
24 W00658 2012-01-01 00:45:00 2012-01-01 00:48:00 3 18th & M St NW 19th St & Pennsylvania Ave NW Registered
25 W00996 2012-01-01 00:45:00 2012-01-01 00:54:00 9 15th & P St NW NaN Registered
26 W00790 2012-01-01 00:46:00 2012-01-01 00:53:00 7 15th & P St NW NaN Registered
27 W01213 2012-01-01 00:48:00 2012-01-01 01:04:00 16 Massachusetts Ave & Dupont Circle NW 5th St & Massachusetts Ave NW Registered
28 W00981 2012-01-01 00:49:00 2012-01-01 00:55:00 6 Park Rd & Holmead Pl NW Columbia Rd & Belmont St NW Registered
29 W01270 2012-01-01 00:49:00 2012-01-01 00:59:00 10 17th & Corcoran St NW 16th & Harvard St NW Registered
... ... ... ... ... ... ... ...
2412494 W01430 2012-12-31 09:09:00 2012-12-31 09:20:00 11 15th St & Massachusetts Ave SE North Capitol St & F St NW Subscriber
2412495 W01486 2012-12-31 09:09:00 2012-12-31 09:28:00 19 Lincoln Park / 13th & East Capitol St NE 17th & Rhode Island Ave NW Subscriber
2412496 W00703 2012-12-31 09:08:00 2012-12-31 09:16:00 8 Braddock Rd Metro Market Square / King St & Royal St Subscriber
2412497 W00186 2012-12-31 09:08:00 2012-12-31 09:19:00 11 16th & Harvard St NW 24th & N St NW Subscriber
2412498 W00190 2012-12-31 09:08:00 2012-12-31 09:19:00 11 Columbia Rd & Georgia Ave NW Calvert St & Woodley Pl NW Subscriber
2412499 W20898 2012-12-31 09:08:00 2012-12-31 09:14:00 6 7th & R St NW / Shaw Library 5th & K St NW Subscriber
2412500 W20903 2012-12-31 09:08:00 2012-12-31 09:18:00 10 17th & Rhode Island Ave NW 10th & E St NW Subscriber
2412501 W00189 2012-12-31 09:08:00 2012-12-31 09:18:00 10 Adams Mill & Columbia Rd NW 24th & N St NW Subscriber
2412502 W20946 2012-12-31 09:07:00 2012-12-31 09:17:00 10 7th & F St NW / National Portrait Gallery 21st & I St NW Subscriber
2412503 W01438 2012-12-31 09:07:00 2012-12-31 09:12:00 5 11th & H St NE Columbus Circle / Union Station Subscriber
2412504 W00110 2012-12-31 09:07:00 2012-12-31 09:20:00 13 14th & V St NW 1st & M St NE Subscriber
2412505 W00122 2012-12-31 09:06:00 2012-12-31 09:08:00 2 N Quincy St & Wilson Blvd Central Library / N Quincy St & 10th St N Subscriber
2412506 W01397 2012-12-31 09:06:00 2012-12-31 09:13:00 7 Lincoln Park / 13th & East Capitol St NE Columbus Circle / Union Station Subscriber
2412507 W00078 2012-12-31 09:05:00 2012-12-31 09:27:00 22 10th & Monroe St NE Eastern Market / 7th & North Carolina Ave SE Subscriber
2412508 W00586 2012-12-31 09:05:00 2012-12-31 09:10:00 5 20th St & Florida Ave NW 20th & L St NW Subscriber
2412509 W01417 2012-12-31 09:05:00 2012-12-31 09:23:00 18 17th & Corcoran St NW Smithsonian / Jefferson Dr & 12th St SW Subscriber
2412510 W00282 2012-12-31 09:05:00 2012-12-31 09:15:00 10 5th & K St NW 13th & H St NE Subscriber
2412511 W00574 2012-12-31 09:04:00 2012-12-31 09:15:00 11 11th & H St NE Maryland & Independence Ave SW Subscriber
2412512 W00986 2012-12-31 09:04:00 2012-12-31 09:18:00 14 14th & R St NW 18th St & Pennsylvania Ave NW Subscriber
2412513 W20079 2012-12-31 09:02:00 2012-12-31 09:10:00 8 Lincoln Park / 13th & East Capitol St NE Columbus Circle / Union Station Subscriber
2412514 W01142 2012-12-31 09:02:00 2012-12-31 09:06:00 4 Thomas Circle 17th & K St NW / Farragut Square Subscriber
2412515 W20888 2012-12-31 09:02:00 2012-12-31 09:06:00 4 27th & Crystal Dr Crystal City Metro / 18th & Bell St Subscriber
2412516 W00025 2012-12-31 09:02:00 2012-12-31 09:11:00 9 14th & Rhode Island Ave NW 20th & E St NW Subscriber
2412517 W01059 2012-12-31 09:01:00 2012-12-31 09:07:00 6 15th & P St NW 17th & K St NW / Farragut Square Subscriber
2412518 W20913 2012-12-31 09:01:00 2012-12-31 09:12:00 11 13th & D St NE 7th & F St NW / National Portrait Gallery Subscriber
2412519 W00885 2012-12-31 09:01:00 2012-12-31 09:09:00 8 New Hampshire Ave & T St NW 22nd & I St NW / Foggy Bottom Subscriber
2412520 W00384 2012-12-31 09:01:00 2012-12-31 09:18:00 17 1st & M St NE US Dept of State / Virginia Ave & 21st St NW Subscriber
2412521 W20102 2012-12-31 09:00:00 2012-12-31 09:12:00 12 4th & East Capitol St NE Smithsonian / Jefferson Dr & 12th St SW Subscriber
2412522 W00746 2012-12-31 09:00:00 2012-12-31 09:11:00 11 21st & M St NW 13th St & New York Ave NW Subscriber
2412523 W20982 2012-12-31 09:00:00 2012-12-31 09:09:00 9 16th & Harvard St NW 17th & K St NW Subscriber

2412524 rows × 7 columns


In [26]:
usage.groupby("cust_type")["duration_mins"].mean()


Out[26]:
cust_type
Casual        41.493881
Registered    12.091809
Subscriber    11.383536
Name: duration_mins, dtype: float64

The casual bikers tend to ride their bikes longer per bike session in comparison to registered and subscriber bikers.


In [28]:
season_group = weather.groupby(weather["season_desc"])["no_casual_riders", "no_reg_riders"].sum()

In [29]:
season_group


Out[29]:
no_casual_riders no_reg_riders
season_desc
fall 76969 438507
spring 125958 445315
summer 130641 510838
winter 39197 282151

There are always more no regular riders than no casual riders. Summer has the highest number of riders in both no causal riders and no regular riders categories.


In [32]:
weather.groupby(weather['weather_desc'])['no_casual_riders', 'no_reg_riders'].sum()


Out[32]:
no_casual_riders no_reg_riders
weather_desc
Clear, Few clouds, Partly cloudy, Partly cloudy 269074 1153811
Light Snow, Light Rain + Thunderstorm + Scattered clouds, Light Rain + Scattered clouds 1902 10855
Mist + Cloudy, Mist + Broken clouds, Mist + Few clouds, Mist 101789 512145

Both the no casual riders and no regular riders like to ride their bikes when the weater is clear, few clouds, partly cloudy. Riders tend to avoid weather codition that has light snow, light rain, thunderstorm, scattered clouds and light rain.


In [ ]: