用法:
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。