How to access Data from Pandas Series
In this post, we will learn how to access data from pandas Series. To access the elements from Series we use the index operator [ ].
In the previous post, we have learned about how to create pandas series. If you want to learn how to create a Series the link is given below-
How to create Pandas Series
 We can access data from Series in two ways
 1. Access data from pandas Series with position
Data from the Series can be accessed similar to that in an array.
Accessing the first element
As we know the counting starts from zero for the array which means the first element is stored at the zeroth position and so on.
s=pd.Series([1,2,3,4,5], index=[‘a’,’b’,’c’,’d’,’e’])
print (s[0])
its output is as follows
1
Accessing the last element
s=pd.Series([1,2,3,4,5], index=[‘a’,’b’,’c’,’d’,’e’])
print (s[4])
its output is as follows
5
Accessing the first four element
s=pd.Series([7,3,9,4,1,8,2], index=[‘a’,’b’,’c’,’d’,’e’,’f’,’g’])
print (s[:4])
its output is as follows
a | 7 |
b | 3 |
c | 9 |
d | 4 |
2. Accessing data from Series using index (label)
Accessing a single element using index value
Accessing multiple elements using a list of index values
Series, DataFrame and Panel in pandas python
Types of Python Libraries
Python Pandas Series and how to create Series
How to access data from pandas series
How to create Pandas DataFrame
How to add new Column in DataFrame
How to add new Row in DataFrame
How to select Row and Column in DataFrame
How to delete Column in DataFrame
How to delete Row in DataFrame
Pandas Math Operation on column