-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-pandas.py
More file actions
29 lines (20 loc) · 765 Bytes
/
3-pandas.py
File metadata and controls
29 lines (20 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pandas
weather_data=pandas.read_csv('./weather-data.csv')
# print(weather_data)
# print data of a row
# print(weather_data[weather_data.day=='Wednesday'])
# to print the row with max temperature
# print(weather_data[weather_data.temp==weather_data.temp.max()])
# to convert monday's temperature into fahrehheit from celsius
monday_data =(weather_data[weather_data.day=='Monday'])
monday_temp = int(monday_data.temp)
print(monday_temp * 9 / 5 + 32)
# creating data_frame from scratch
data_dict={
'students': ['Amy', 'James', 'Angela'],
'scores': [76, 56, 65]
}
# this converts the dictionary into a dataframe
data=pandas.DataFrame(data_dict)
# this saves the dataframe in the harddrive as 'new_data.csv'
data.to_csv('./new_data.csv')