Posts

Showing posts from July, 2019

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 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

LOC,IX,Mean

1)loc[specific index row and clm] df.loc[0] #0 index ni row aavi jse df.loc[99]#99 index ni row aavi jse 2)IX{loc na badle lx lkhvanu] df.ix[0] or df.ix[[0,99,76]] # 0,99,76 number ni index aavse or df.ix[[0,99,76],['HP','Attack']] HP Attack 0 45 49 99 30 35 76 65 90 or df.ix[[0,99,76],[5,6]] HP Attack 0 45 49 99 30 35 76 65 90 3)Mean mean=df['HP'].mean()#'HP pokemon no dataset mean 69.25875