Contents

  1. Python Setup and Installation
  2. Introduction to Python Libraries and its Overview
  3. PyCharm IDE Installation
  4. Series and its creation in different ways
  5. Indexing in Series or Accessing Series Elements
  6. Slicing in Series or Subset Accessing in Series
  7. Series Attributes and functionalites
  8. Concept of np.NaN and more about indexing
  9. Head and Tail Functions in Series
  10. Mathematical Functions in Series Objects
  11. DataFrame in Python Pandas and its creation in different ways
  12. DataFrame from CSV and Text File
  13. DataFrame Attributes and other functionalites
  14. Iloc Methods for subset accessing in DataFrame
  15. Loc Methods for subset accessing in DataFrame
  16. Adding Columns to DataFrame
  17. Adding Rows to DataFrame
  18. Deleting Columns from DataFrame
  19. Deleting Rows from DataFrame
  20. Renaming Row and Column Labels in DataFrame

Slicing in Series

Slicing is an accessing technique or method in which we can access a particular part of series. If we consider whole series as a set, then using slicing we can access subset of that particular series using the start and the end index. Basically, it is useful in extrating a particular part of series.

SYNTAX: print(ser_name[start_index:end_index])

When slicing is done using positional indices that is default indices, the end index(extreme) is excluded in selection and when slicing is done using user-defined indices, the end index(extreme) is included in selection.

#importing required libraries
import pandas as pd

#creating a list of names
list1 = ['Aman', 'Raghav', 'Shubham', 'Rohit', 'Yash']
ser = pd.Series(list1)

#accessing element of the series through slicing
print(ser[2:4])

OUTPUT:

2 Shubham
3 Rohit
dtype: object
#4 being excluded in selection
Download Notes