BUG: Calling tz_localize suppresses ValueError when converting from NaT to np.int64 #39162
Closed
2 of 3 tasks
Labels
Bug
Closing Candidate
May be closeable, needs more eyeballs
Datetime
Datetime data dtype
Dtype Conversions
Unexpected or buggy dtype conversions
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
Problem description
The code snippet above prints
-9223372036854775808
(-263) instead of raising aValueError
, which is the behavior that would occur iftz_localize
were not called.Expected Output
Should raise a
ValueError: Cannot convert NaT values to integer
.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 3e89b4c
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.8.0-36-generic
Version : #40~20.04.1-Ubuntu SMP Wed Jan 6 10:15:55 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.0
numpy : 1.19.5
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 51.0.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 : 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
The text was updated successfully, but these errors were encountered: