Skip to content

Commit e8e7bbd

Browse files
committed
ENH: set __module__ for objects in pandas Scalars API
1 parent e51039a commit e8e7bbd

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

pandas/_libs/tslibs/period.pyx

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ from pandas._libs.tslibs.offsets import (
115115
BDay,
116116
)
117117

118+
from pandas.util._decorators import set_module
119+
118120
cdef:
119121
enum:
120122
INT32_MIN = -2_147_483_648LL
@@ -2662,6 +2664,7 @@ cdef class _Period(PeriodMixin):
26622664
return period_format(self.ordinal, base, fmt)
26632665

26642666

2667+
@set_module("pandas")
26652668
class Period(_Period):
26662669
"""
26672670
Represents a period of time.

pandas/_libs/tslibs/timedeltas.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import collections
22
import warnings
33

4+
from pandas.util._decorators import set_module
45
from pandas.util._exceptions import find_stack_level
56

67
cimport cython
@@ -1771,7 +1772,7 @@ cdef class _Timedelta(timedelta):
17711772

17721773
# Python front end to C extension type _Timedelta
17731774
# This serves as the box for timedelta64
1774-
1775+
@set_module("pandas")
17751776
class Timedelta(_Timedelta):
17761777
"""
17771778
Represents a duration, the difference between two dates or times.

pandas/_libs/tslibs/timestamps.pyx

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import datetime as dt
5050
from pandas._libs.tslibs cimport ccalendar
5151
from pandas._libs.tslibs.base cimport ABCTimestamp
5252

53+
from pandas.util._decorators import set_module
5354
from pandas.util._exceptions import find_stack_level
5455

5556
from pandas._libs.tslibs.conversion cimport (
@@ -1263,7 +1264,7 @@ cdef class _Timestamp(ABCTimestamp):
12631264
# Python front end to C extension type _Timestamp
12641265
# This serves as the box for datetime64
12651266

1266-
1267+
@set_module("pandas")
12671268
class Timestamp(_Timestamp):
12681269
"""
12691270
Pandas replacement for python datetime.datetime object.

pandas/tests/api/test_api.py

+3
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,6 @@ def test_pandas_array_alias():
405405

406406
def test_set_module():
407407
assert pd.DataFrame.__module__ == "pandas"
408+
assert pd.Period.__module__ == "pandas"
409+
assert pd.Timestamp.__module__ == "pandas"
410+
assert pd.Timedelta.__module__ == "pandas"

0 commit comments

Comments
 (0)