Skip to content

Commit 3fb33d6

Browse files
authored
DOC: Fixing EX01 - Added examples (#54278)
* PerformanceWarning example * Removed extra line * Clean-up output * skip doctest as warnings are suppressed
1 parent ed25532 commit 3fb33d6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

ci/code_checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6363

6464
MSG='Partially validate docstrings (EX01)' ; echo $MSG
6565
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
66-
pandas.errors.PerformanceWarning \
6766
pandas.errors.PyperclipException \
6867
pandas.errors.PyperclipWindowsException \
6968
pandas.errors.UnsortedIndexError \

pandas/errors/__init__.py

+20
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ class NullFrequencyError(ValueError):
4646
class PerformanceWarning(Warning):
4747
"""
4848
Warning raised when there is a possible performance impact.
49+
50+
Examples
51+
--------
52+
>>> df = pd.DataFrame({"jim": [0, 0, 1, 1],
53+
... "joe": ["x", "x", "z", "y"],
54+
... "jolie": [1, 2, 3, 4]})
55+
>>> df = df.set_index(["jim", "joe"])
56+
>>> df
57+
jolie
58+
jim joe
59+
0 x 1
60+
x 2
61+
1 z 3
62+
y 4
63+
>>> df.loc[(1, 'z')] # doctest: +SKIP
64+
# PerformanceWarning: indexing past lexsort depth may impact performance.
65+
df.loc[(1, 'z')]
66+
jolie
67+
jim joe
68+
1 z 3
4969
"""
5070

5171

0 commit comments

Comments
 (0)