在此程序中,我们将声明两个熊猫系列并比较它们的元素。解决问题之前,我们需要将Pandas库导入本地IDE。这可以通过在我们的本地计算机上安装Pandas来完成。安装Pandas的命令是-
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