Skip to content

BUG: NaNs converted to 1970-01-01 instead of NaT #26964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timcera opened this issue Jun 20, 2019 · 5 comments
Closed

BUG: NaNs converted to 1970-01-01 instead of NaT #26964

timcera opened this issue Jun 20, 2019 · 5 comments
Labels
Needs Info Clarification about behavior needed to assess issue

Comments

@timcera
Copy link
Contributor

timcera commented Jun 20, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
import numpy as np                                                                                              

s = pd.Series([1, 2, np.nan, np.nan, np.nan]).astype('M8[ns]')
print(s)

0 1970-01-01 00:00:00.000000001
1 1970-01-01 00:00:00.000000002
2 1970-01-01 00:00:00.000000000
3 1970-01-01 00:00:00.000000000
4 1970-01-01 00:00:00.000000000
dtype: datetime64[ns]

Problem description

This problem is on the master branch as of commit baeb1bf

All 'nan' like entries, when converted to datetime should be NaT.

Several tests are failing, the example above is from pandas/tests/test_algos.py

Expected Output

0 1970-01-01 00:00:00.000000001
1 1970-01-01 00:00:00.000000002
2 NaT
3 NaT
4 NaT
dtype: datetime64[ns]

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: baeb1bf
python: 3.7.3.final.0
python-bits: 32
OS: Linux
OS-release: 3.18.0-19095-g86596f58eadf
machine: aarch64
processor:
byteorder: little
LC_ALL: en_US.utf8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.25.0.dev0+761.gbaeb1bf92.dirty
pytest: 4.5.0
pip: 19.1.1
setuptools: 41.0.1
Cython: 0.29.10
numpy: 1.16.3
scipy: 1.3.0
pyarrow: None
xarray: 0.12.1
IPython: 7.5.0
sphinx: 2.0.1
patsy: None
dateutil: 2.8.0
pytz: 2019.1
blosc: 1.8.1
bottleneck: None
tables: 3.5.2
numexpr: 2.6.9
feather: None
matplotlib: 3.1.0
openpyxl: 2.6.2
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.8
lxml.etree: 4.3.4
bs4: 4.7.1
html5lib: 0.9999999
sqlalchemy: 1.3.4
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: 0.2.2

@TomAugspurger
Copy link
Contributor

I don't think baeb1bf is related. Do you need to rebuild your C extensions?

@timcera
Copy link
Contributor Author

timcera commented Jun 20, 2019

Yes.

I was working on my development branch to finish #26631 and kept on getting these test errors. Couldn't figure out why anything that I was working on would affect this, so...

git checkout master
python setup.py develop

Correctly re-compiled the one pyx file that I am working on in my development branch, and the 'nan' to 'NaT' tests still fail.

I understand the confusion about me mentioning baeb1bf. I don't mean to imply that commit is the source of this problem, in fact I know that it isn't. I have had these failing tests since I began work on #26631. I just wanted to indicate the version of the code that I am using.

@WillAyd
Copy link
Member

WillAyd commented Jun 22, 2019

I cannot reproduce this on master. Here's my pd.show_versions FWIW not sure if 32 bit or macOS vs Linux for OP matters

INSTALLED VERSIONS

commit : a14874f
python : 3.7.3.final.0
python-bits : 64
OS : Darwin
OS-release : 18.6.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 0.25.0.dev0+782.ga14874f3e
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : 0.29.8
pytest : 4.5.0
hypothesis : 4.23.6
sphinx : 2.0.1
blosc : None
feather : None
xlsxwriter : 1.1.8
lxml.etree : 4.3.3
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.5.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : 1.2.1
fastparquet : 0.3.0
gcsfs : None
matplotlib : 3.1.0
numexpr : 2.6.9
openpyxl : 2.6.1
pandas_gbq : None
pyarrow : 0.11.1
pytables : None
s3fs : 0.2.1
scipy : 1.2.1
sqlalchemy : 1.3.3
tables : 3.5.1
xarray : 0.12.1
xlrd : None
xlwt : 1.3.0
xlsxwriter : 1.1.8

@TomAugspurger TomAugspurger added the Needs Info Clarification about behavior needed to assess issue label Jun 24, 2019
@timcera
Copy link
Contributor Author

timcera commented Jul 5, 2019

Seems like a problem with my numpy install...

np.array([1,2,np.nan,np.nan]).astype('M8[ns]')

array(['1970-01-01T00:00:00.000000001', '1970-01-01T00:00:00.000000002',
   '1970-01-01T00:00:00.000000000', '1970-01-01T00:00:00.000000000'],
  dtype='datetime64[ns]')

Closing

@timcera timcera closed this as completed Jul 5, 2019
@timcera
Copy link
Contributor Author

timcera commented Jul 7, 2019

Here is the numpy bug. Three years old...

numpy/numpy#8325

raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Dec 27, 2019
At least some of these are pd.Timestamp(np.nan) = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877419 https://bugs.debian.org/877754


Gbp-Pq: Name mark_tests_working_on_intel_armhf.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Mar 1, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Apr 9, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Apr 10, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue May 10, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Jul 2, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Aug 20, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Aug 31, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Oct 26, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Nov 7, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Dec 11, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Dec 20, 2020
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Jan 15, 2021
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Dec 24, 2021
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Jan 16, 2022
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Feb 6, 2022
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Mar 12, 2022
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Apr 18, 2022
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Jul 14, 2022
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
raspbian-autopush pushed a commit to raspbian-packages/pandas that referenced this issue Nov 20, 2022
pd.Series([np.nan]).astype('datetime64[ns]')[0] = pd.NaT on x86
but 1970-01-01 on arm* because float NaN -> int is undefined:
numpy/numpy#8325
pandas-dev/pandas#17792
pandas-dev/pandas#26964

On s390x it's the maximum _positive_ value (2**63-1 ns = year 2262)

On riscv64 one test case raises an exception
(though I suspect not the general case since there aren't more).
 
Author: Andreas Tille <[email protected]>, Graham Inggs <[email protected]>, Rebecca N. Palmer <[email protected]>
Bug-Debian: https://bugs.debian.org/877754
Forwarded: no


Gbp-Pq: Name xfail_tests_nonintel_nannat.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Info Clarification about behavior needed to assess issue
Projects
None yet
Development

No branches or pull requests

3 participants