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 >
A Practical, No-Nonsense Introduction to Python Development. You already know you want to learn Python, and a smarter way to learn Python 3 is to learn by doing. The Python Workshop focuses on buil...
Learning to code is tremendous fun as you can get instant results, no matter how much more you have to learn. In fact, it’s such fun creating games and programs that it feels effortless once you’r...
The ability to identify patterns is an essential component of sensory intelli- gent machines. Pattern recognition is therefore an indispensible component of the so-called “Intelligent Control System...
The Pragmatic Programmer: Your Journey To Mastery, 20th Anniversary Edition (2nd Edition). The Pragmatic Programmer is one of those rare technical books that you will read, reread, and re-read over...