Informatics Practices
Write Python code to create a Series object Temp1 that stores temperatures of seven days in it. Take any random seven temperatures.
Python Pandas
7 Likes
Answer
import pandas as pd
temperatures = [28.0, 30.4, 26.5, 29.4, 27.0, 31.2, 25.8]
Temp1 = pd.Series(temperatures)
print(Temp1)Output
0 28.0
1 30.4
2 26.5
3 29.4
4 27.0
5 31.2
6 25.8
dtype: float64
Answered By
3 Likes
Related Questions
Find the error in the following code ? Suggest the solution.
>>> topDfRollNo Name Marks Sec A 115 Pavni 97.5 Sec B 236 Rishi 98.0 Sec C 307 Preet 98.5 Sec D 422 Paula 98.0topDf.del['Sec D']Find the error in the following code considering the same dataframe topDf given in the previous question.
(i) topDf.rename(index=['a', 'b', 'c', 'd'])
(ii) topDf.rename(columns = {})
Write Python code to create a Series object Temp2 storing temperatures of seven days of week. Its indexes should be 'Sunday', 'Monday',… 'Saturday'.
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.