What is pandas-python?
Introduction and Installation
Pandas is python module that makes data science easy and effective
Weather dataset
Questions?
1. What was the maximum temparature in new york in the month of january?
2. On which days did it rains?
3. What was the average speed of wind during the month?
First we will see in python code
In [3]:
# now we will see in pandas
import pandas as pd
df = pd.read_csv("nyc_weather.csv")
df
Out[3]:
Sea Level
EST Temperature DewPoint Humidity VisibilityMiles WindSpeedMPH PrecipitationIn CloudCover Events WindDirDegrees
PressureIn
0 1/1/2016 38 23 52 30.03 10 8.0 0 5 NaN
1 1/2/2016 36 18 46 30.02 10 7.0 0 3 NaN
2 1/3/2016 40 21 47 29.86 10 8.0 0 1 NaN
3 1/4/2016 25 9 44 30.05 10 9.0 0 3 NaN
4 1/5/2016 20 -3 41 30.57 10 5.0 0 0 NaN
5 1/6/2016 33 4 35 30.50 10 4.0 0 0 NaN
6 1/7/2016 39 11 33 30.28 10 2.0 0 3 NaN
7 1/8/2016 39 29 64 30.20 10 4.0 0 8 NaN
8 1/9/2016 44 38 77 30.16 9 8.0 T 8 Rain
9 1/10/2016 50 46 71 29.59 4 NaN 1.8 7 Rain
10 1/11/2016 33 8 37 29.92 10 NaN 0 1 NaN
11 1/12/2016 35 15 53 29.85 10 6.0 T 4 NaN
12 1/13/2016 26 4 42 29.94 10 10.0 0 0 NaN
13 1/14/2016 30 12 47 29.95 10 5.0 T 7 NaN
14 1/15/2016 43 31 62 29.82 9 5.0 T 2 NaN
15 1/16/2016 47 37 70 29.52 8 7.0 0.24 7 Rain
Fog-
16 1/17/2016 36 23 66 29.78 8 6.0 0.05 6
Snow
17 1/18/2016 25 6 53 29.83 9 12.0 T 2 Snow
18 1/19/2016 22 3 42 30.03 10 11.0 0 1 NaN
19 1/20/2016 32 15 49 30.13 10 6.0 0 2 NaN
20 1/21/2016 31 11 45 30.15 10 6.0 0 1 NaN
21 1/22/2016 26 6 41 30.21 9 NaN 0.01 3 Snow
Fog-
22 1/23/2016 26 21 78 29.77 1 16.0 2.31 8
Snow
23 1/24/2016 28 11 53 29.92 8 6.0 T 3 Snow
24 1/25/2016 34 18 54 30.25 10 3.0 0 2 NaN
25 1/26/2016 43 29 56 30.03 10 7.0 0 2 NaN
26 1/27/2016 41 22 45 30.03 10 7.0 T 3 Rain
26 1/27/2016 41 22 45 30.03 10 7.0 T 3 Rain
Sea Level
EST
27 1/28/2016 Temperature
37 DewPoint
20 Humidity
51 PressureIn
29.90 VisibilityMiles
10 WindSpeedMPH
5.0 PrecipitationIn
0 CloudCover
1 Events
NaN WindDirDegrees
28 1/29/2016 36 21 50 29.58 10 8.0 0 4 NaN
29 1/30/2016 34 16 46 30.01 10 7.0 0 0 NaN
30 1/31/2016 46 28 52 29.90 10 5.0 0 0 NaN
In [0]:
#get the maximum temparature
df['Temperature'].max()
Out[0]:
50
In [0]:
#to know which day it rains
df['EST'][df['Events'] == 'Rain']
Out[0]:
8 1/9/2016
9 1/10/2016
15 1/16/2016
26 1/27/2016
Name: EST, dtype: object
In [0]:
#3. average wind speed
df['WindSpeedMPH'].mean()
Out[0]:
6.8928571428571432
Installation
pip3 install pandas