@@ -1294,6 +1294,8 @@ def assert_series_equal(
1294
1294
rtol = 1.0e-5 ,
1295
1295
atol = 1.0e-8 ,
1296
1296
obj = "Series" ,
1297
+ * ,
1298
+ check_index = True ,
1297
1299
):
1298
1300
"""
1299
1301
Check that left and right Series are equal.
@@ -1353,6 +1355,10 @@ def assert_series_equal(
1353
1355
obj : str, default 'Series'
1354
1356
Specify object name being compared, internally used to show appropriate
1355
1357
assertion message.
1358
+ check_index : bool, default True
1359
+ Whether to check index equivalence. If False, then compare only values.
1360
+
1361
+ .. versionadded:: 1.3.0
1356
1362
1357
1363
Examples
1358
1364
--------
@@ -1388,18 +1394,20 @@ def assert_series_equal(
1388
1394
if check_flags :
1389
1395
assert left .flags == right .flags , f"{ repr (left .flags )} != { repr (right .flags )} "
1390
1396
1391
- # index comparison
1392
- assert_index_equal (
1393
- left .index ,
1394
- right .index ,
1395
- exact = check_index_type ,
1396
- check_names = check_names ,
1397
- check_exact = check_exact ,
1398
- check_categorical = check_categorical ,
1399
- rtol = rtol ,
1400
- atol = atol ,
1401
- obj = f"{ obj } .index" ,
1402
- )
1397
+ if check_index :
1398
+ # GH #38183
1399
+ assert_index_equal (
1400
+ left .index ,
1401
+ right .index ,
1402
+ exact = check_index_type ,
1403
+ check_names = check_names ,
1404
+ check_exact = check_exact ,
1405
+ check_categorical = check_categorical ,
1406
+ rtol = rtol ,
1407
+ atol = atol ,
1408
+ obj = f"{ obj } .index" ,
1409
+ )
1410
+
1403
1411
if check_freq and isinstance (left .index , (pd .DatetimeIndex , pd .TimedeltaIndex )):
1404
1412
lidx = left .index
1405
1413
ridx = right .index
@@ -1704,6 +1712,10 @@ def assert_frame_equal(
1704
1712
assert col in right
1705
1713
lcol = left .iloc [:, i ]
1706
1714
rcol = right .iloc [:, i ]
1715
+ # GH #38183
1716
+ # use check_index=False, because we do not want to run
1717
+ # assert_index_equal for each column,
1718
+ # as we already checked it for the whole dataframe before.
1707
1719
assert_series_equal (
1708
1720
lcol ,
1709
1721
rcol ,
@@ -1717,6 +1729,7 @@ def assert_frame_equal(
1717
1729
obj = f'{ obj } .iloc[:, { i } ] (column name="{ col } ")' ,
1718
1730
rtol = rtol ,
1719
1731
atol = atol ,
1732
+ check_index = False ,
1720
1733
)
1721
1734
1722
1735
0 commit comments