diff --git a/ci/code_checks.sh b/ci/code_checks.sh index def6de320d632..4eecee4be4731 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -119,10 +119,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.errors.AccessorRegistrationWarning \ pandas.errors.AttributeConflictWarning \ pandas.errors.DataError \ - pandas.errors.EmptyDataError \ pandas.errors.IncompatibilityWarning \ pandas.errors.InvalidComparison \ - pandas.errors.InvalidIndexError \ pandas.errors.InvalidVersion \ pandas.errors.IntCastingNaNError \ pandas.errors.LossySetitemError \ diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index d4bcc9cee7155..1ead53d2cfc4d 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -124,6 +124,14 @@ class DtypeWarning(Warning): class EmptyDataError(ValueError): """ Exception raised in ``pd.read_csv`` when empty data or header is encountered. + + Examples + -------- + >>> from io import StringIO + >>> empty = StringIO() + >>> pd.read_csv(empty) + Traceback (most recent call last): + EmptyDataError: No columns to parse from file """ @@ -234,6 +242,20 @@ class DuplicateLabelError(ValueError): class InvalidIndexError(Exception): """ Exception raised when attempting to use an invalid index key. + + Examples + -------- + >>> idx = pd.MultiIndex.from_product([["x", "y"], [0, 1]]) + >>> df = pd.DataFrame([[1, 1, 2, 2], + ... [3, 3, 4, 4]], columns=idx) + >>> df + x y + 0 1 0 1 + 0 1 1 2 2 + 1 3 3 4 4 + >>> df[:, 0] + Traceback (most recent call last): + InvalidIndexError: (slice(None, None, None), 0) """