Professional Documents
Culture Documents
Vector Operations On Pandas Series
Vector Operations On Pandas Series
Vector Operations On Pandas Series
Note:- But when you apply this check with the Series object inside [ ] ,
you will find that it returns filtered result containing only the values
that return True for the given Boolean expression.
Modifying elements of a series
The data values of a series object can be modified through
item assignment.
The syntax is :
series[index]=new value
or
series[start index:stop index]=new value
#Eg- Consider the series S1,S2,S3,S4 .
S1 S2 S3 S4
But if you print the Series S1 , after the previous drop statement,
print(S1)
You can also create a new series element with same name S1,after
drooping the data at index 1.
S1=S1.drop(1)
print(S1)
print(S3.drop(102))
print(S3.drop(1))
print(S4.drop("Orange"))
print(S4.drop(1))
#D- Delete the data at the index ‘b’ and ‘e’ of S2.
print(S2.drop(['b','e']))
print(S5)
#A-To change the index of the series S2 to [‘y’ ,’x’, ’z’, ’m’,’n’], we
write the statement:
Note:- The size of new index array must match with existing index
array’s size.
2. Reindexing
Sometimes you need to create a similar object but with a
different order of same indexes. You can use reindexing for
the same purpose.
Syntax is :
seriesname = seriesname.reindex=[new index array]
#Eg1- Consider the series S2
print(S2)