Q. Given a dataframe namely wdf as shown below:

	minTemp	maxTemp	Rainfall	Evaporation
0	1	8.0	24.3	0.0
1	2	14.0	26.9	3.6
2	3	13.7	23.4	3.6
3	4	13.3	15.5	39.8
4	5	7.6	16.1	2.8
5	6	6.2	16.9	0.0
6	7	6.1	18.2	0.2
7	8	8.3	17.8	0.0
8	9	8.8	19.5	0.0
9	10	8.4	22.8	16.2
10	11	9.1	25.2	0.0
11	12	8.5	27.3	0.2
12	13	10.1	27.9	0.0
13	14	12.1	30.9	0.0
14	15	10.1	31.2	0.0
15	16	12.4	32.1 	0.0
16	17	13.8	31.2	0.0
17	18	11.7	30.0	1.2
18	19	12.4	32.3	0.6
19	20	15.6	33.4	0.0
20	21	15.3	33.4	0.0

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

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

(iii) Write command to compute sum of every row of the dataframe.

(iv) Write command to compute average of all the columns for last 10 rows only.

(v) Write command to compute average maxTemp, Rainfall for first 10 rows.


Answer :-

(i) wdf.sum()
(ii) wdf['Rainfall'].mean ()
(iii) wdf.sum (axis = 1)
(iv) wdf.loc [11:, ].mean()
(v) wdf.loc[:11, 'maxtemp': 'Rainfall'].mean()

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post