Informatics Practices
If Ser is a Series type object having 30 values, then how are statements (a), (b) and (c), (d) similar and different ?
(a) print(Ser.head())
(b) print(Ser.head(8))
(c) print(Ser.tail())
(d) print(Ser.tail(11))
Python Pandas
3 Likes
Answer
The statements (a), (b), (c) and (d) are all used to view the values from a pandas Series object Ser. However, they differ in the number of values they display.
(a) print(Ser.head()): This statement will display the first 5 values from the Series Ser.
(b) print(Ser.head(8)): This statement will display the first 8 values from the Series Ser.
(c) print(Ser.tail()): This statement will display the last 5 values from the Series Ser.
(d) print(Ser.tail(11)): This statement will display the last 11 values from the Series Ser.
Answered By
2 Likes
Related Questions
Why does following code cause error ?
s1 = pd.Series(range(1, 15, 3), index = list('abcd'))Why does following code cause error ?
s1 = pd.Series(range(1, 15, 3), index = list('ababa')) print(s1['ab'])What advantages does dataframe offer over series data structure ? If you have similar data stored in multiple series and a single dataframe, which one would you prefer and why ?
Create a DataFrame in Python from the given list :
[['Divya', 'HR', 95000], ['Mamta', 'Marketing', 97000], ['Payal', 'IT', 980000], ['Deepak', 'Sales', 79000]]
Also give appropriate column headings as shown below :
Name Department Salary 0 Divya HR 95000 1 Mamta Marketing 97000 2 Payal IT 980000 3 Deepak Sales 79000