Python pandas Group by
Ex
Group BY
step 1:df=pd.read_csv('ferrovial.csv')
df
step 2:data=df.groupby('city')
data
#aatlu lkheya pche output nai aave next line add karve
Group BY
step 1:df=pd.read_csv('ferrovial.csv')
df
step 2:data=df.groupby('city')
data
#aatlu lkheya pche output nai aave next line add karve
for city,city_df in data:
print(city)
print(city_df)
step 3:particular city joiti hoy to aa step add karvu
data.get_group("kerala")
Step 4:data.max() #max value aavse
step 5:data.mean()#mean value aavse
step 6:data.describe() # descibe lkheshu to mean,median,max,min bdhu j aavse
Date | Close | High | Low | Open | Volume | city | |||||
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 02-01-2007 | 12.850 | 12.940 | 12.710 | 12.900 | 3080000.0 | vado | ||||
1 | 03-01-2007 | 12.660 | 12.860 | 12.600 | 12.850 | 2740000.0 | vado | ||||
2 | 04-01-2007 | 12.450 | 12.720 | 12.380 | 12.590 | 2330000.0 | vado | ||||
3 | 05-01-2007 | 12.200 | 12.360 | 12.070 | 12.170 | 1930000.0 | vado | ||||
4 | 08-01-2007 | 12.190 | 12.280 | 12.150 | 12.220 | 1970000.0 | vado | ||||
5 | 09-01-2007 | 12.450 | 12.500 | 12.220 | 12.390 | 2560000.0 | ahem | ||||
6 | 10-01-2007 | 12.280 | 12.480 | 12.260 | 12.400 | 2490000.0 | ahem | ||||
7 | 11-01-2007 | 12.350 | 12.490 | 12.200 | 12.310 | 1760000.0 | ahem | ||||
8 | 12-01-2007 | 12.500 | 12.530 | 12.310 | 12.590 | 1600000.0 | kerala | ||||
9 | 15-01-2007 | 12.650 | 12.760 | 12.590 | 12.640 | 1310000.0 | kerala | ||||
10 | 16-01-2007 | 12.430 | 12.740 | 12.360 | 12.560 | 1250000.0 | surat | ||||
Comments
Post a Comment