Skip to content

BUG: pd.date_range not factoring in nanoseconds in freq #46877

Closed
@galipremsagar

Description

@galipremsagar

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
print(pd.__version__)
x = pd.date_range(end='1970-01-01 00:00:00', periods=10, freq=pd.DateOffset(**{'hours': 10, 'days': 57, 'nanoseconds': 3}), name="a")
print(x.to_numpy())

1.4.2
['1968-08-02T06:00:00.000000000' '1968-09-28T16:00:00.000000000'
 '1968-11-25T02:00:00.000000000' '1969-01-21T12:00:00.000000000'
 '1969-03-19T22:00:00.000000000' '1969-05-16T08:00:00.000000000'
 '1969-07-12T18:00:00.000000000' '1969-09-08T04:00:00.000000000'
 '1969-11-04T14:00:00.000000000' '1970-01-01T00:00:00.000000000']

Issue Description

While generating date ranges, nanoseconds specified in freq are not being factored in.

Expected Behavior

['1968-08-02T06:00:00.000000000', '1968-09-28T16:00:00.000000003',
       '1968-11-25T02:00:00.000000006', '1969-01-21T12:00:00.000000009',
       '1969-03-19T22:00:00.000000012', '1969-05-16T08:00:00.000000015',
       '1969-07-12T18:00:00.000000018', '1969-09-08T04:00:00.000000021',
       '1969-11-04T14:00:00.000000024', '1970-01-01T00:00:00.000000027']

Installed Versions

INSTALLED VERSIONS

commit : 945c9ed
python : 3.9.6.final.0
python-bits : 64
OS : Darwin
OS-release : 21.4.0
Version : Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.3.4
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 22.0.4
setuptools : 59.8.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions