Python Pandas - 检查两个 Index 对象是否具有相似的对象属性和类型
要检查两个Index对象是否具有相似的对象属性和类型,请使用index1.identical(index2)方法。
首先,导入所需的库——
import pandas as pd
创建Pandasindex1和index2-
index1 = pd.Index([15, 25, 35, 45, 55]) index2 = pd.Index([15, 25, 35, 45, 55])
显示index1和index2-
print("Pandas Index1...\n",index1)
print("Pandas Index2...\n",index2)检查两个索引对象是否具有相似的属性和类型-
print("\nThe two Index objects have similar attributes and types?" "\n",index1.identical(index2))示例
以下是代码-
import pandas as pd
#创建Pandasindex1和index2
index1 = pd.Index([15, 25, 35, 45, 55])
index2 = pd.Index([15, 25, 35, 45, 55])
#显示index1和index2
print("Pandas Index1...\n",index1)
print("Pandas Index2...\n",index2)
print("\nThe two Index objects have similar attributes and types?" "\n",index1.identical(index2))输出结果这将产生以下输出-
Pandas Index1... Int64Index([15, 25, 35, 45, 55], dtype='int64') Pandas Index2... Int64Index([15, 25, 35, 45, 55], dtype='int64') The two Index objects have similar attributes and types? True
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下