Skip to content

Commit 9cf4b28

Browse files
Infer the unit based on the frequency
Modified the pd.date_range function based on the provided frequency and the start/stop timestamp.
1 parent 339a554 commit 9cf4b28

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/core/indexes/datetimes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,14 @@ def date_range(
10031003
"""
10041004
if freq is None and com.any_none(periods, start, end):
10051005
freq = "D"
1006+
1007+
if unit is None and freq is not None:
1008+
offset = to_offset(freq)
1009+
if offset is not None:
1010+
unit = offset.n
1011+
1012+
if unit is None:
1013+
unit = 'ns'
10061014

10071015
dtarr = DatetimeArray._generate_range(
10081016
start=start,

0 commit comments

Comments
 (0)