In the package overview, they talk about the two primary data structures of pandas: series and a data
frame.
import pandas
data = pandas.read_csv("weather_data.csv")
print(data)
print(data["temp"])
data_dict = data.to_dict()
temp_list = data["temp"].to_list()
import pandas
data = pandas.read_csv("weather_data.csv")
#Get the average of temp column
#1
temp_list = data["temp"].to_list()
average = sum(temp_list) / len(temp_list)
#2
print(data["temp"].mean())
#3
import statistics
print(statistics.mean(temp_list))
#Get the max number of temp
data["temp"].max()
#Get data in Columns
data["condition"]
data.condition
#Calcualte the data
monday = data[data.day == "Monday"]
monday_temp = int(monday.temp) * 9/5 + 32
print(monday_temp)
import pandas
data_dict = {
"students": ["Amy", "James", "Angela"],
"score": [76, 56, 65]
}
data = pandas.DataFrame(data_dict)
data.to_csv("new_data.csv")
students score
0 Amy 76
1 James 56
2 Angela 65