Skip to content

Commit d4bac86

Browse files
authored
ENH: set __module__ on to_datetime, to_timedelta, to_numeric (#62368)
1 parent f388d99 commit d4bac86

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

pandas/core/tools/datetimes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
ArrayLike,
4242
DateTimeErrorChoices,
4343
)
44+
from pandas.util._decorators import set_module
4445
from pandas.util._exceptions import find_stack_level
4546

4647
from pandas.core.dtypes.common import (
@@ -666,6 +667,7 @@ def to_datetime(
666667
) -> DatetimeIndex: ...
667668

668669

670+
@set_module("pandas")
669671
def to_datetime(
670672
arg: DatetimeScalarOrArrayConvertible | DictConvertible,
671673
errors: DateTimeErrorChoices = "raise",

pandas/core/tools/numeric.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Timedelta,
1616
Timestamp,
1717
)
18+
from pandas.util._decorators import set_module
1819
from pandas.util._validators import check_dtype_backend
1920

2021
from pandas.core.dtypes.cast import maybe_downcast_numeric
@@ -46,6 +47,7 @@
4647
)
4748

4849

50+
@set_module("pandas")
4951
def to_numeric(
5052
arg,
5153
errors: DateTimeErrorChoices = "raise",

pandas/core/tools/timedeltas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
disallow_ambiguous_unit,
2323
parse_timedelta_unit,
2424
)
25+
from pandas.util._decorators import set_module
2526

2627
from pandas.core.dtypes.common import is_list_like
2728
from pandas.core.dtypes.dtypes import ArrowDtype
@@ -73,6 +74,7 @@ def to_timedelta(
7374
) -> TimedeltaIndex: ...
7475

7576

77+
@set_module("pandas")
7678
def to_timedelta(
7779
arg: str
7880
| int

pandas/tests/api/test_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ def test_set_module():
453453
assert pd.date_range.__module__ == "pandas"
454454
assert pd.bdate_range.__module__ == "pandas"
455455
assert pd.timedelta_range.__module__ == "pandas"
456+
assert pd.to_datetime.__module__ == "pandas"
457+
assert pd.to_timedelta.__module__ == "pandas"
458+
assert pd.to_numeric.__module__ == "pandas"
456459
assert pd.NamedAgg.__module__ == "pandas"
457460
assert api.typing.SeriesGroupBy.__module__ == "pandas.api.typing"
458461
assert api.typing.DataFrameGroupBy.__module__ == "pandas.api.typing"

0 commit comments

Comments
 (0)