Skip to content

Commit a0bff50

Browse files
committed
Use to_datetime instead of dtype=“datetime64[D]”
1 parent 6b9d15c commit a0bff50

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/core/indexes/accessors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ def isocalendar(self):
239239
240240
Examples
241241
--------
242-
>>> pd.Series(["2020-01-01"], dtype="datetime64[D]").dt.isocalendar
242+
>>> pd.to_datetime(pd.Series(["2020-01-01"])).dt.isocalendar
243243
year week day
244244
0 2020 1 3
245-
>>> ser = pd.Series(["2010-01-01", pd.NaT], dtype="datetime64[D]")
245+
>>> ser = pd.to_datetime(pd.Series(["2010-01-01", pd.NaT]))
246246
>>> ser.dt.isocalendar
247247
year week day
248248
0 2009.0 53.0 5.0
249249
1 NaN NaN NaN
250-
>>> pd.Series(["2019-12-31"], dtype="datetime64[D]").dt.isocalendar.week
250+
>>> pd.to_datetime(pd.Series(["2019-12-31"])).dt.isocalendar.week
251251
0 1
252252
Name: week, dtype: int32
253253
"""

pandas/tests/series/test_datetime_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def test_setitem_with_different_tz(self):
682682
],
683683
)
684684
def test_isocalendar(self, input_series, expected_output, expected_type):
685-
ser = pd.Series(input_series, dtype="datetime64[D]")
685+
ser = pd.to_datetime(pd.Series(input_series))
686686
expected_frame = pd.DataFrame(
687687
expected_output, columns=["year", "week", "day"]
688688
).astype(expected_type)

0 commit comments

Comments
 (0)