BUG: to_datetime()'s origin does not use unit specified in the parameter · Issue #42624 · pandas-dev/pandas (original) (raw)


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

pd.to_datetime(1, unit='s')

Timestamp('1970-01-01 00:00:01')

pd.to_datetime(1, unit='s', origin=1)

Current --> Timestamp('1970-01-01 00:00:01')

Expected -> Timestamp('1970-01-01 00:00:02')

pd.to_datetime(1, unit='s', origin=1000000000)

Current --> Timestamp('1970-01-01 00:00:02')

Expected -> Timestamp('2001-09-09 01:46:41')

Problem description

The numeric values of origin should be parsed as number of units defined by unit

Output of pd.show_versions()

INSTALLED VERSIONS

commit : f00ed8f
python : 3.9.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19042
machine : AMD64
processor : Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.950

pandas : 1.3.0
numpy : 1.21.0
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1.3
setuptools : 57.0.0
Cython : 0.29.23
pytest : 6.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.25.0
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : 2021.06.1
fastparquet : None
gcsfs : None
matplotlib : 3.4.2
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.0
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : 2.0.1
xlwt : None
numba : 0.53.1