Page 19 - Informatics_Practices_Fliipbook_Class12
P. 19
dtype: float64
>>> students.loc[101:106:2]
output:
101 90.5
103 95.0
106 100.0
dtype: float64
>>> students.loc[:103]
output:
101 90.5
102 70.0
103 95.0
dtype: float64
It is important to note that when using actual labels as indexes in a Pandas series, both the starting and ending indexes
are included in the final output. However, when using iloc, the value at the last index of the range is excluded from
the final output, as demonstrated below:
>>> students.iloc[0:3]
output:
101 90.5
102 70.0
103 95.0
dtype: float64
C T 01 1. Write Python statements to create the following two series storing the names and salaries of employees
in the company, with employee id appearing as the index:
empNames
E001 Raman
E002 Sukhvir
E003 Saumya
E004 Rittik
E005 Arya
E006 Pankaj
E007 Samarth
dtype: object
empSalary
E001 75000
E002 95000
E003 50000
E004 80000
E005 55000
E006 80000
E007 45000
dtype: int64
NOTE!! The questions in Coding Task section of the remaining chapter will refer above two series.
2. Write Python statements to retrieve the value and index part of the series: empNames and empSalary.
3. Retrieve the name of first employee.
4. Retrieve the names of last three employees from empNames.
5. Retrieve the salary of employees with code E001, E003, and E004.
Data Handling using Pandas 5

