Skip to content
7 changes: 7 additions & 0 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from pandas._libs.tslibs.offsets import BDay
from pandas.compat import pa_version_under10p1
from pandas.errors import PerformanceWarning
from pandas.util._decorators import set_module
from pandas.util._exceptions import find_stack_level

from pandas.core.dtypes.base import (
Expand Down Expand Up @@ -155,6 +156,7 @@ class CategoricalDtypeType(type):


@register_extension_dtype
@set_module("pandas")
class CategoricalDtype(PandasExtensionDtype, ExtensionDtype):
"""
Type for categorical data with the categories and orderedness.
Expand Down Expand Up @@ -706,6 +708,7 @@ def index_class(self) -> type_t[CategoricalIndex]:


@register_extension_dtype
@set_module("pandas")
class DatetimeTZDtype(PandasExtensionDtype):
"""
An ExtensionDtype for timezone-aware datetime data.
Expand Down Expand Up @@ -974,6 +977,7 @@ def index_class(self) -> type_t[DatetimeIndex]:


@register_extension_dtype
@set_module("pandas")
class PeriodDtype(PeriodDtypeBase, PandasExtensionDtype):
"""
An ExtensionDtype for Period data.
Expand Down Expand Up @@ -1215,6 +1219,7 @@ def index_class(self) -> type_t[PeriodIndex]:


@register_extension_dtype
@set_module("pandas")
class IntervalDtype(PandasExtensionDtype):
"""
An ExtensionDtype for Interval data.
Expand Down Expand Up @@ -1691,6 +1696,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:


@register_extension_dtype
@set_module("pandas")
class SparseDtype(ExtensionDtype):
"""
Dtype for data stored in :class:`SparseArray`.
Expand Down Expand Up @@ -2130,6 +2136,7 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None:


@register_extension_dtype
@set_module("pandas")
class ArrowDtype(StorageExtensionDtype):
"""
An ExtensionDtype for PyArrow data types.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
Appender,
cache_readonly,
doc,
set_module,
)
from pandas.util._exceptions import (
find_stack_level,
Expand Down Expand Up @@ -315,6 +316,7 @@ def _new_Index(cls, d):
return cls.__new__(cls, **d)


@set_module("pandas")
class Index(IndexOpsMixin, PandasObject):
"""
Immutable sequence used for indexing and alignment.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pandas.util._decorators import (
cache_readonly,
doc,
set_module,
)

from pandas.core.dtypes.common import is_scalar
Expand Down Expand Up @@ -76,6 +77,7 @@
Categorical,
wrap=True,
)
@set_module("pandas")
class CategoricalIndex(NDArrayBackedExtensionIndex):
"""
Index based on an underlying :class:`Categorical`.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pandas.util._decorators import (
cache_readonly,
doc,
set_module,
)

from pandas.core.dtypes.common import is_scalar
Expand Down Expand Up @@ -126,6 +127,7 @@ def _new_DatetimeIndex(cls, d):
+ DatetimeArray._bool_ops,
DatetimeArray,
)
@set_module("pandas")
class DatetimeIndex(DatetimeTimedeltaMixin):
"""
Immutable ndarray-like of datetime64 data.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from pandas.util._decorators import (
Appender,
cache_readonly,
set_module,
)
from pandas.util._exceptions import rewrite_exception

Expand Down Expand Up @@ -202,6 +203,7 @@ def _new_IntervalIndex(cls, d):
IntervalArray,
)
@inherit_names(["is_non_overlapping_monotonic", "closed"], IntervalArray, cache=True)
@set_module("pandas")
class IntervalIndex(ExtensionIndex):
_typ = "intervalindex"

Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
Appender,
cache_readonly,
doc,
set_module,
)
from pandas.util._exceptions import find_stack_level

Expand Down Expand Up @@ -195,6 +196,7 @@ def new_meth(self_or_cls, *args, **kwargs):
return cast(F, new_meth)


@set_module("pandas")
class MultiIndex(Index):
"""
A multi-level, or hierarchical, index object for pandas objects.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pandas.util._decorators import (
cache_readonly,
doc,
set_module,
)

from pandas.core.dtypes.common import is_integer
Expand Down Expand Up @@ -81,6 +82,7 @@ def _new_PeriodIndex(cls, **d):
wrap=True,
)
@inherit_names(["is_leap_year"], PeriodArray)
@set_module("pandas")
class PeriodIndex(DatetimeIndexOpsMixin):
"""
Immutable ndarray holding ordinal values indicating regular periods in time.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from pandas.util._decorators import (
cache_readonly,
doc,
set_module,
)

from pandas.core.dtypes.base import ExtensionDtype
Expand Down Expand Up @@ -74,6 +75,7 @@ def min_fitting_element(start: int, step: int, lower_limit: int) -> int:
return start + abs(step) * no_steps


@set_module("pandas")
class RangeIndex(Index):
"""
Immutable Index implementing a monotonic integer range.
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Timedelta,
to_offset,
)
from pandas.util._decorators import set_module

from pandas.core.dtypes.common import (
is_scalar,
Expand Down Expand Up @@ -50,6 +51,7 @@
],
TimedeltaArray,
)
@set_module("pandas")
class TimedeltaIndex(DatetimeTimedeltaMixin):
"""
Immutable Index of timedelta64 data.
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,19 @@ def test_util_in_top_level(self):

def test_set_module():
assert pd.DataFrame.__module__ == "pandas"
assert pd.CategoricalDtype.__module__ == "pandas"
assert pd.PeriodDtype.__module__ == "pandas"
assert pd.IntervalDtype.__module__ == "pandas"
assert pd.SparseDtype.__module__ == "pandas"
assert pd.ArrowDtype.__module__ == "pandas"
assert pd.Index.__module__ == "pandas"
assert pd.CategoricalIndex.__module__ == "pandas"
assert pd.DatetimeIndex.__module__ == "pandas"
assert pd.IntervalIndex.__module__ == "pandas"
assert pd.MultiIndex.__module__ == "pandas"
assert pd.PeriodIndex.__module__ == "pandas"
assert pd.RangeIndex.__module__ == "pandas"
assert pd.TimedeltaIndex.__module__ == "pandas"
assert pd.Period.__module__ == "pandas"
assert pd.Timestamp.__module__ == "pandas"
assert pd.Timedelta.__module__ == "pandas"