+2 votes
in Class 12 by kratos

Given a data frame df1 as shown below:

| City | Maxtemp | MinTemp | RainFall |
| Delhi | 40 | 32 | 24.1 |
| Bengaluru | 31 | 25 | 36.2 |
| Chennai | 35 | 27 | 40.8 |
| Mumbai | 29 | 21 | 35.2 |
| Kolkata | 39 | 23 | 41.8 |

(i) Write command to compute sum of every column of the data frame.

(ii) Write command to compute mean of column Rainfall.

(iii) Write command to compute average maxTemp, Rainfall for first 5 rows

1 Answer

+6 votes
by kratos
 
Best answer

(i) df1.sum()

(ii) df1[‘Rainfall’].mean()

(iii) df1.loc[:11, ‘maxtemp’:’Rainfall’].mean( )

...