用法:
cudf.testing.testing.assert_index_equal(left, right, exact='equiv', check_names: bool = True, check_less_precise: Union[bool, int] = False, check_exact: bool = True, check_categorical: bool = True, check_order: bool = True, rtol: float = 1e-05, atol: float = 1e-08, obj: str = 'Index')
检查左右索引是否相等
此函数旨在比较两个索引并输出任何差异。附加参数允许改变执行的相等检查的严格性。
- left: index
左索引比较
- right: index
要比较的正确索引
- exact:bool 或 {‘equiv’},默认 ‘equiv’
是否检查Index类,dtype和inferred_type是否相同。如果‘equiv’,那么 RangeIndex 也可以替代 Int8Index、Int16Index、Int32Index、Int64Index。
- check_names:布尔值,默认为真
是否检查名称属性。
- check_less_precise:bool 或 int,默认为 False
尚不支持
- check_exact:布尔值,默认为 False
是否准确比较数字。
- check_categorical:布尔值,默认为真
是否准确比较内部分类。
- check_order:布尔值,默认为真
是否比较索引条目的顺序以及它们的值。如果为 True,则两个索引必须以相同的顺序包含相同的元素。如果为 False,则两个索引必须包含相同的元素,但顺序不限。
- rtol:浮点数,默认 1e-5
相对容差。仅在
check_exact
为 False 时使用。- atol:浮点数,默认 1e-8
绝对的宽容。仅在
check_exact
为 False 时使用。- obj:str,默认“索引”
指定要比较的对象名称,内部用于显示适当的断言消息。
参数:
例子:
>>> import cudf >>> id1 = cudf.Index([1, 2, 3, 4]) >>> id2 = cudf.Index([1, 2, 3, 5]) >>> cudf.testing.assert_index_equal(id1, id2) ...... ...... AssertionError: ColumnBase are different values are different (25.0 %) [left]: [1 2 3 4] [right]: [1 2 3 5]
>>> id2 = cudf.Index([1, 2, 3, 4], name="b") >>> cudf.testing.assert_index_equal(id1, id2) ...... ...... AssertionError: Index are different name mismatch [left]: a [right]: b
这将顺利通过:
>>> id2 = cudf.Index([1, 2, 3, 4], name="a") >>> cudf.testing.assert_index_equal(id1, id2)
相关用法
- Python cudf.testing.testing.assert_series_equal用法及代码示例
- Python cudf.testing.testing.assert_frame_equal用法及代码示例
- Python cudf.to_numeric用法及代码示例
- Python cudf.to_datetime用法及代码示例
- Python cudf.core.column.string.StringMethods.is_vowel用法及代码示例
- Python cudf.Series.ceil用法及代码示例
- Python cudf.core.column.string.StringMethods.endswith用法及代码示例
- Python cudf.Series.update用法及代码示例
- Python cudf.DataFrame.mod用法及代码示例
- Python cudf.DataFrame.isin用法及代码示例
- Python cudf.core.column.string.StringMethods.title用法及代码示例
- Python cudf.DataFrame.rmul用法及代码示例
- Python cudf.Series.max用法及代码示例
- Python cudf.DatetimeIndex.dayofweek用法及代码示例
- Python cudf.DataFrame.apply用法及代码示例
- Python cudf.core.column.string.StringMethods.contains用法及代码示例
- Python cudf.core.column.string.StringMethods.rsplit用法及代码示例
- Python cudf.DataFrame.exp用法及代码示例
- Python cudf.Series.head用法及代码示例
- Python cudf.DataFrame.drop用法及代码示例
注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.testing.testing.assert_index_equal。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。