Description
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- (optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
import pandas as pd
print("Timedelta")
print(pd.Timestamp("2020-01-01 18:00:00.000000001") + pd.Timedelta(days=1))
print("Dateoffset")
print(pd.Timestamp("2020-01-01 18:00:00.000000001") + pd.DateOffset(days=1))
Output:
$ python bug.py
Timedelta
2020-01-02 18:00:00.000000001
Dateoffset
sys:1: UserWarning: Discarding nonzero nanoseconds in conversion
2020-01-02 18:00:00.000000001
Problem description
This program produces correct answers in both cases, but gives a warning about discarding nanoseconds when using DateOffset. I think this is because internally it is converted to a pydatetime somewhere. The warning does not occur with Timedelta, presumably because it's just adding the raw values.
Expected Output
I expect not to get a warning
Timedelta
2020-01-02 18:00:00.000000001
Dateoffset
2020-01-02 18:00:00.000000001
Output of pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.9.2.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-33-generic
Version : #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.utf8
LOCALE : en_US.UTF-8
pandas : 1.2.4
numpy : 1.20.2
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 49.6.0.post20210108
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 : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None