-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (34 loc) · 959 Bytes
/
main.py
File metadata and controls
43 lines (34 loc) · 959 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# with open('weather_data.csv') as file:
# data = file.readlines()
# print(data)
# import csv
#
# with open('weather_data.csv') as data_file:
# data = csv.reader(data_file)
# temperatures = []
# for row in data:
# if row[1]!= 'temp':
# temperatures.append(int(row[1]))
# # print(row)
# print(temperatures)
import pandas as pd
data = pd.read_csv('weather_data.csv')
print(data["temp"])
# data_dict = data.to_dict()
# print(data_dict)
data_list = data["temp"].tolist()
print(data_list)
print(f"The Average Temperature is {sum(data_list)/len(data_list)}")
print(data["temp"].mean())
max_temp = data["temp"].max()
print(data[data.temp == max_temp])
monday = data[data.day == "Monday"]
print(monday.condition)
# create dataframe from scratch
data_dict = {
"students":["Amy","Jamie","Anshika"],
"scores":[75,25,98]
}
new_df = pd.DataFrame(data_dict)
print(new_df)
new_df.to_csv("newdata.csv")