Skip to content

Commit 909017c

Browse files
DeaMariaLeonim-vinicius
authored and
im-vinicius
committed
DOC: Fixing EX01 - Added examples (pandas-dev#53331)
* Removed Index.item from code_checks * Added examples for 2 errors
1 parent 50ef7c7 commit 909017c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
119119
pandas.errors.AccessorRegistrationWarning \
120120
pandas.errors.AttributeConflictWarning \
121121
pandas.errors.DataError \
122-
pandas.errors.EmptyDataError \
123122
pandas.errors.IncompatibilityWarning \
124123
pandas.errors.InvalidComparison \
125-
pandas.errors.InvalidIndexError \
126124
pandas.errors.InvalidVersion \
127125
pandas.errors.IntCastingNaNError \
128126
pandas.errors.LossySetitemError \

pandas/errors/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ class DtypeWarning(Warning):
124124
class EmptyDataError(ValueError):
125125
"""
126126
Exception raised in ``pd.read_csv`` when empty data or header is encountered.
127+
128+
Examples
129+
--------
130+
>>> from io import StringIO
131+
>>> empty = StringIO()
132+
>>> pd.read_csv(empty)
133+
Traceback (most recent call last):
134+
EmptyDataError: No columns to parse from file
127135
"""
128136

129137

@@ -234,6 +242,20 @@ class DuplicateLabelError(ValueError):
234242
class InvalidIndexError(Exception):
235243
"""
236244
Exception raised when attempting to use an invalid index key.
245+
246+
Examples
247+
--------
248+
>>> idx = pd.MultiIndex.from_product([["x", "y"], [0, 1]])
249+
>>> df = pd.DataFrame([[1, 1, 2, 2],
250+
... [3, 3, 4, 4]], columns=idx)
251+
>>> df
252+
x y
253+
0 1 0 1
254+
0 1 1 2 2
255+
1 3 3 4 4
256+
>>> df[:, 0]
257+
Traceback (most recent call last):
258+
InvalidIndexError: (slice(None, None, None), 0)
237259
"""
238260

239261

0 commit comments

Comments
 (0)