series.eq() is used to compare each element of the Caller series with the missing series. It returns True for every element that is equal to an element in the passed series.
Note: results are returned based on a comparison of caller series = other series.
Syntax: Series.eq (other, level = None, fill_value = None)
other: other series to be compared with
level: int or name of level in case of multi level
fill_value: Value to be replaced instead of NaN
Return type: Boolean series
Example # 1: Handling null values p >
In this example, two series are created using
pd.Series () . The series contains several zero values and several equal values with the same indices.
.eq () are compared using
.eq () and 5 is passed to fill_value to replace NaN values with 5.
As shown in the output, True was returned wherever the value in the caller row was equal to the value in the passed row. You can also see that the zero values have been replaced with 5 and the comparison has been done using that value.
Example # 2: Calling Series with str objects Output: b >
In this example, two series are created using pd.Series (). The series also contains some string values. In the case of strings, the comparison is performed against their
# pandas module import
pandas as pd
# numpy module import
numpy as np
# create series 1
# create episode 2
# Replace NaN
# call and return to the result variable
series1.eq (series2, fill_value
As you can see from the output, in the case of strings, the comparison was made using their ASCII values. True was returned wherever the string in the Caller series was equal to the string in the passed series.
Output: b >