Skip to content

Commit c539d1f

Browse files
authored
DOC: Fixing EX01 - Added examples (#54168)
Examples AccessorRegistrationWarning, AttributeConflictWarning, DataError
1 parent ab85d7a commit c539d1f

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +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.AccessorRegistrationWarning \
67-
pandas.errors.AttributeConflictWarning \
68-
pandas.errors.DataError \
6966
pandas.errors.IncompatibilityWarning \
7067
pandas.errors.InvalidComparison \
7168
pandas.errors.IntCastingNaNError \

doc/source/reference/testing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Exceptions and warnings
2525
:toctree: api/
2626

2727
errors.AbstractMethodError
28-
errors.AccessorRegistrationWarning
2928
errors.AttributeConflictWarning
3029
errors.CategoricalConversionWarning
3130
errors.ChainedAssignmentError

pandas/errors/__init__.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,6 @@ class MergeError(ValueError):
184184
"""
185185

186186

187-
class AccessorRegistrationWarning(Warning):
188-
"""
189-
Warning for attribute conflicts in accessor registration.
190-
"""
191-
192-
193187
class AbstractMethodError(NotImplementedError):
194188
"""
195189
Raise this error instead of NotImplementedError for abstract methods.
@@ -281,6 +275,13 @@ class DataError(Exception):
281275
282276
For example, calling ``ohlc`` on a non-numerical column or a function
283277
on a rolling window.
278+
279+
Examples
280+
--------
281+
>>> ser = pd.Series(['a', 'b', 'c'])
282+
>>> ser.rolling(2).sum()
283+
Traceback (most recent call last):
284+
DataError: No numeric types to aggregate
284285
"""
285286

286287

@@ -552,6 +553,17 @@ class AttributeConflictWarning(Warning):
552553
Occurs when attempting to append an index with a different
553554
name than the existing index on an HDFStore or attempting to append an index with a
554555
different frequency than the existing index on an HDFStore.
556+
557+
Examples
558+
--------
559+
>>> idx1 = pd.Index(['a', 'b'], name='name1')
560+
>>> df1 = pd.DataFrame([[1, 2], [3, 4]], index=idx1)
561+
>>> df1.to_hdf('file', 'data', 'w', append=True) # doctest: +SKIP
562+
>>> idx2 = pd.Index(['c', 'd'], name='name2')
563+
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], index=idx2)
564+
>>> df2.to_hdf('file', 'data', 'a', append=True) # doctest: +SKIP
565+
AttributeConflictWarning: the [index_name] attribute of the existing index is
566+
[name1] which conflicts with the new [name2]...
555567
"""
556568

557569

@@ -644,7 +656,6 @@ class InvalidComparison(Exception):
644656

645657
__all__ = [
646658
"AbstractMethodError",
647-
"AccessorRegistrationWarning",
648659
"AttributeConflictWarning",
649660
"CategoricalConversionWarning",
650661
"ClosedFileError",

0 commit comments

Comments
 (0)