diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 0dea8235e9d3f..1bcd1c5fcf4eb 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -132,6 +132,12 @@ from pandas.io.formats.printing import pprint_thing import pandas.plotting + +# Customized "cover all bases" local Exception +class DataFrameError(NotImplementedError, TypeError, AttributeError): + pass + + if TYPE_CHECKING: from pandas.core.groupby.generic import DataFrameGroupBy from pandas.io.formats.style import Styler @@ -411,7 +417,9 @@ def _constructor(self) -> Type["DataFrame"]: @property def _constructor_expanddim(self): - raise NotImplementedError("Not supported for DataFrames!") + raise DataFrameError( + "Property 'constructor_expanddim' is not supported for DataFrames!" + ) # ---------------------------------------------------------------------- # Constructors diff --git a/pandas/tests/frame/test_subclass.py b/pandas/tests/frame/test_subclass.py index a2e7dc527c4b8..9eda5f4504a75 100644 --- a/pandas/tests/frame/test_subclass.py +++ b/pandas/tests/frame/test_subclass.py @@ -5,8 +5,14 @@ from pandas import DataFrame, Index, MultiIndex, Series import pandas._testing as tm +import inspect + class TestDataFrameSubclassing: + + def test_get_members(): + inspect.getmembers(pd.DataFrame()) + def test_frame_subclassing_and_slicing(self): # Subclass frame and ensure it returns the right class on slicing it # In reference to PR 9632