Signup/Sign In
PUBLISHED ON: MARCH 17, 2021

Pandas DataFrame ge() Method

In this tutorial, we will learn the Python pandas DataFrame.ge() method. This method is used to get greater than or equal to of dataframe and other, element-wise (binary operator get). It returns the DataFrame of bool type that is the result of the comparison.

The below is the syntax of the DataFrame.ge() method.

Syntax

DataFrame.ge(other, axis='columns', level=None)

Parameters

other: scalar, sequence, Series, or DataFrame. Any single or multiple element data structure, or list-like object.

axis:{0 or ‘index’, 1 or ‘columns’}, default ‘columns’. Whether to compare by the index (0 or ‘index’) or columns (1 or ‘columns’).

level: int or label. Broadcast across a level, matching Index values on the passed MultiIndex level.

Example 1: Comparing the DataFrame by using the DataFrame.ge() Method

Here, we are comparing with a scalar using the DataFrame.ge() method that returns a bool type dataframe.

#importing pandas as pd
import pandas as pd
#importing numpy as np
import numpy as np
#creating the DataFrame
df=pd.DataFrame({"A":[200,500],"B":[60,250],"C":[150,1]})
print("--------The DataFrame is---------")
print(df)
print("----After applying ge function-----")
print(df.ge(200))

Once we run the program we will get the following output.


--------The DataFrame is---------
A B C
0 200 60 150
1 500 250 1
----After applying ge method-----
A B C
0 True False False
1 True True False

Example 2: Comparing the DataFrame by using the DataFrame.ge() Method

Here, we are comparing with a Series using the DataFrame.ge() method. See the below example.

#importing pandas as pd
import pandas as pd
#creating the DataFrame
df=pd.DataFrame({"A":[200,500],"B":[60,250],"C":[150,1]})
print("--------The DataFrame is---------")
print(df)
series = pd.Series([150, 200,150]) 
print("----After applying ge function-----")
print(df.ge(series,axis=0))

Once we run the program we will get the following output.


--------The DataFrame is---------
A B C
0 200 60 150
1 500 250 1
----After applying ge method-----
A B C
0 True False True
1 True True False
2 False False False

Example 3: Comparing the DataFrame by using the DataFrame.ge() Method

Here, we are comparing with other DataFrame using the DataFrame.ge() method. See the below example.

#importing pandas as pd
import pandas as pd
#creating the DataFrame
df_1=pd.DataFrame({"A":[200,500],"B":[60,250],"C":[150,1]})
print("--------The first DataFrame is---------")
print(df_1)
df_2=pd.DataFrame({"A":[200,550],"B":[65,251],"C":[100,10]})
print("--------The second DataFrame is---------")
print(df_2)
print("----After applying ge function-----")
print(df_1.ge(df_2))

Once we run the program we will get the following output.


--------The first DataFrame is---------
A B C
0 200 60 150
1 500 250 1
--------The second DataFrame is---------
A B C
0 200 65 100
1 550 251 10
----After applying ge method-----
A B C
0 True False True
1 False False False

Conclusion:

In this tutorial, we learned the Python pandas DataFrame.ge() method. We learned the syntax, parameters and by applying this method on the DataFrame we understood the DataFrame.ge() method.



About the author:
I like writing about Python, and frameworks like Pandas, Numpy, Scikit, etc. I am still learning Python. I like sharing what I learn with others through my content.