- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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
Python program to compare two Pandas series
In this program, we will declare two Pandas series and compare their elements. Before we solve the problem, we need to import the Pandas library into our local IDE. This can be done by installing Pandas on our local machine. The command for installing Pandas is −
pip install pandas
Series1 = [2,4,6,8,10]
Series2 = [1,3,5,7,9]
Step 1: Define two Pandas series using the Series() function of Pandas library.
Step 2: Compare the series using greater than, less than, and equal-to operators.
import pandas as pd series1 = pd.Series([2,4,6,8,10]) series2 = pd.Series([1,3,5,7,9]) print("Greater Than: \n",series1>series2) print("\nLess Than: \n",series1<series2) print("\nEquals : \n", series1 == series2)
Greater Than: 0 True 1 True 2 True 3 True 4 True dtype: bool Less Than: 0 False 1 False 2 False 3 False 4 False dtype: bool Equals : 0 False 1 False 2 False 3 False 4 False dtype: bool
- How to compare two Pandas Series Objects by Applying Greater Than Condition using gt() Function?
- How to compare two DataFrames in Python Pandas with missing values
- How to compare elements of a series by Python list using pandas series.ge() function?
- How to compare elements of a series by Python list using pandas series.gt() function?
- Java Program to compare two sets
- Java Program to Compare Two Strings
- PHP program to compare two dates
- Write a Python code to concatenate two Pandas series into a single series without repeating the index
- Python Pandas - Convert the DateTimeIndex to Series
- Java Program to compare two Boolean Arrays
- Java Program to compare two Byte Arrays
- Program to compare two fractions in C
- Program to Compare two strings in Java
- Java Program to Compare two strings lexicographically
- How to append a pandas Series object to another Series in Python?