Python Wheather Lab Work
import pandas as pd
weather_data= {
'day':['4/05/2022', '4/04 /2023', '10/02/2011', '30/09/2021', '9/10/2001','13/05/2019'],
'temp':['20','30','45','39','25','51'],
'windspeed':['7','3','5','9'],
'event':['rain', 'sunny', 'Litt cloudy', 'cloudy', 'sunny', 'windy'],
}
df= pd.DataFrame(weather_data)
rows, columns= df.shape
df.tail(2)
df[2:5]
df.columns
df['day']
df[['day' 'event']]
df['temp'].max()
df['temp'].mean()
df['temp'].min()
df['temp'].std()
df.describe()
df['temp']=df['temp'].astype(int)
df[df['temp']>32]
df[df.tempdf.temp.max()]
df[['day', 'temp']][df.tempdf.temp.max()]
#df-index()
df.set_index("day", inplace=True)
df.loc['4/04/2023']
df.reset_index(inplace=True)
Comments
Post a Comment