Pandas series.ge ()
is used to compare each element of the Caller series against the missing series. It returns True for every element that is greater than or equal to an element in the passed series.
Note: results are returned based on series comparison of callers " = other series.
Syntax: Series.ge (other, level = None, fill_value = None, axis = 0)
Parameters:
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
axis: 0 or ’index’ to apply method by rows and 1 or ’ columns’ to apply by columns.Return type: Boolean series
Example # 1: NaN processing
This example creates two series using pd.Series ()
. The series contains several zero values and several equal values with the same indices. The series are compared using the .ge ()
method and 7 is passed to the fill_value parameter to replace the NaN values with 7.
|
Output:
As shown in the output, True was returned wherever the value in the caller row was greater than or equal to the value in the passed row. You can also see that the zero values have been replaced with 7 and the comparison has been done using that value.
Example # 2: Calling Series with str objects
In this example, two series are created using Output: pd.Series ()
. The series also contains some string values. In the case of strings, the comparison is performed against their # pandas module import
import
pandas as pd
# numpy module import
import
numpy as np
# create series 1
series1
=
pd.Series ([
’A’
,
0
,
’c’
,
43
,
9
,
’e’
, np.nan,
’x’
, np.nan])
# create episode 2
series2
=
pd.Series ([
’v ’
, np.nan,
’ c’
,
23
,
5
,
’D’
,
54
,
’p’
,
19
])
# NaN replacement
replace_nan
=
14
# call and return to the result variable
result
=
series1.ge (series2, fill_value
=
replace_nan)
# display
result
As you can see from the output, in the case of strings, the comparison was performed using their ASCII values.