Q. A series object (say T1) stores the average temperature recorded on each day of a month. Write code to display the temperatures recorded on:

(i) First 7 days

(ii) Last 7 days.


You can understand by Watching video :-




Answer =


import pandas as pd
avg_tem = [28, 30, 25, 35, 37, 39, 28, 28, 30, 25, 35, 37, 39, 28, 28, 30, 25, 35, 37, 39, 28, 28, 30, 25, 35, 37, 39, 28, 28, 30, 25]
Temp1 = pd.Series(avg_tem)

print(f'first 7 days \n {Temp1.head(7)} ')
print(f'last 7 days\n {Temp1.tail(7)} ')

Output :-

first 7 days
 0    28
1    30
2    25
3    35
4    37
5    39
6    28
dtype: int64
last 7 days
 24    35
25    37
26    39
27    28
28    28
29    30
30    25
dtype: int64

>>>

Post a Comment

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

Previous Post Next Post