Skip to content

Commit 1f89b82

Browse files
DOC: add examples to docstrings of assert_ functions (#37844)
Co-authored-by: Marco Gorelli <[email protected]>
1 parent eb4be94 commit 1f89b82

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pandas/_testing.py

+21
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,13 @@ def assert_index_equal(
739739
obj : str, default 'Index'
740740
Specify object name being compared, internally used to show appropriate
741741
assertion message.
742+
743+
Examples
744+
--------
745+
>>> from pandas.testing import assert_index_equal
746+
>>> a = pd.Index([1, 2, 3])
747+
>>> b = pd.Index([1, 2, 3])
748+
>>> assert_index_equal(a, b)
742749
"""
743750
__tracebackhide__ = True
744751

@@ -1205,6 +1212,13 @@ def assert_extension_array_equal(
12051212
Missing values are checked separately from valid values.
12061213
A mask of missing values is computed for each and checked to match.
12071214
The remaining all-valid values are cast to object dtype and checked.
1215+
1216+
Examples
1217+
--------
1218+
>>> from pandas.testing import assert_extension_array_equal
1219+
>>> a = pd.Series([1, 2, 3, 4])
1220+
>>> b, c = a.array, a.array
1221+
>>> assert_extension_array_equal(b, c)
12081222
"""
12091223
if check_less_precise is not no_default:
12101224
warnings.warn(
@@ -1334,6 +1348,13 @@ def assert_series_equal(
13341348
obj : str, default 'Series'
13351349
Specify object name being compared, internally used to show appropriate
13361350
assertion message.
1351+
1352+
Examples
1353+
--------
1354+
>>> from pandas.testing import assert_series_equal
1355+
>>> a = pd.Series([1, 2, 3, 4])
1356+
>>> b = pd.Series([1, 2, 3, 4])
1357+
>>> assert_series_equal(a, b)
13371358
"""
13381359
__tracebackhide__ = True
13391360

scripts/path_to_file.zip

5.06 KB
Binary file not shown.

0 commit comments

Comments
 (0)