Skip to content

Commit 3fb5a2c

Browse files
committed
Attempt unit us to_datetime
1 parent 0320b3c commit 3fb5a2c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pandas/core/tools/datetimes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def to_datetime(
672672
utc: bool = False,
673673
format: str | None = None,
674674
exact: bool | lib.NoDefault = lib.no_default,
675-
unit: str | None = None,
675+
unit: str | None = "us",
676676
origin: str = "unix",
677677
cache: bool = True,
678678
) -> DatetimeIndex | Series | DatetimeScalar | NaTType | None:

pandas/tests/tools/test_to_datetime.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,19 @@ def test_to_datetime_mixed_offsets_with_utc_false_removed(self, date):
17141714
with pytest.raises(ValueError, match=msg):
17151715
to_datetime(date, utc=False)
17161716

1717+
@pytest.mark.parametrize(
1718+
"date",
1719+
[
1720+
"2024-03-22 11:43:01",
1721+
"2024-03-22 11:43:01.002",
1722+
"2024-03-22 11:43:01.002003",
1723+
],
1724+
)
1725+
def test_to_datetime_type(self, date):
1726+
dt = to_datetime([date])
1727+
print("pranav dtype is ", dt.dtype)
1728+
assert dt.dtype == "<M8[us]"
1729+
17171730

17181731
class TestToDatetimeUnit:
17191732
@pytest.mark.parametrize("unit", ["Y", "M"])

0 commit comments

Comments
 (0)