- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to compare elements of a series by Python list using pandas series.ge() function?

By using the series.ge() method we can apply the Greater Than or Equal to comparison operation on elements of the series with a python list. The functionality of this ge() method in pandas series class is to check Greater Than or Equal to compare operation between elements of a series with another.

Here another is one of the parameters of this ge() method, by using this we can give our second input (series or a scalar) and also we can apply this ge() Greater Than or Equal to comparison operation between series and a python list.

## Example 1

In the following example, we will see how the ge() method compares elements of a series with elements of a python list.

import pandas as pd import numpy as np # create pandas Series s = pd.Series([49, 96, 38, 13, 22]) print("Series object:",s) # apply ge() method using a list of integers print("Output:") print(s.ge(other=[1, 92, 30, 29, 59]))

Moreover, we can see how the series.ge() method works on elements of the series and python list.

## Output

The output is given below −

Series object: 0 49 1 96 2 38 3 13 4 22 dtype: int64 Output: 0 True 1 True 2 True 3 False 4 False dtype: bool

The first element in the series object 49 is compared with the first element of the list 1 (49 >= 1) then the corresponding output will be True which is represented in the resultant series object. In the same way, the remaining elements are also compared.

## Example 2

Let’s take another pandas series object and apply the Greater Than or Equal to comparison operation with a list of integers.

import pandas as pd import numpy as np # create pandas Series s = pd.Series({'A':6, 'B':18, "C":None, "D":43, 'E':np.nan, 'F':30 }) print("Series object:",s) # apply ge() method using a list of integers by replacing missing values print("Output:") print(s.ge(other=[1, 19, 30, 29, 88, 59], fill_value=30))

## Explanation

Also, we have replaced the missing values by specifying integer value 30 to the fill_value parameter.

## Output

The output is as follows −

Series object: A 6.0 B 18.0 C NaN D 43.0 E NaN F 30.0 dtype: float64 Output: A True B False C True D True E False F False dtype: bool

The ge() method successfully replaced the missing values by 30 and then compared the elements of two input objects.

- Related Articles
- How to compare elements of a series by Python list using pandas series.gt() function?
- How to compare two Pandas Series Objects by Applying Greater Than Condition using gt() Function?
- How to access Pandas Series elements by using indexing?
- How does the pandas series.ge() method works if the series object contains string type elements?
- Python program to compare two Pandas series
- How to perform the Integer division operation of a pandas Series by a Python list?
- How to create a series from a list using Pandas?
- How to append elements to a Pandas series?
- How to access pandas Series elements using the .iloc attribute?
- How to access pandas Series elements using the .loc attribute?
- Accessing elements of a Pandas Series
- How to remove a group of elements from a pandas series object?
- How to append a pandas Series object to another Series in Python?
- How to access a group of elements from pandas Series using the .iloc attribute with slicing object?
- How to access datetime indexed elements in pandas series?