Skip to content
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

Inconsistent handling of NaN in Timedelta comparison #24726

Closed
ericstarr opened this issue Jan 11, 2019 · 2 comments
Closed

Inconsistent handling of NaN in Timedelta comparison #24726

ericstarr opened this issue Jan 11, 2019 · 2 comments
Labels
Needs Info Clarification about behavior needed to assess issue

Comments

@ericstarr
Copy link

Code Sample, a copy-pastable example if possible

import pandas as pd
import numpy as np

df = pd.DataFrame({
    'td': [
        pd.Timedelta(days=1),
        pd.Timedelta(days=3),
        np.nan,
    ],
})

# Comparison of NaN evaluates to True
df > pd.Timedelta(days=2)

# Comparison of NaN evaluates to False
df['td'] > pd.Timedelta(days=2)

Problem description

Comparing a dataframe of Timedeltas to a single Timedelta returns True where the dataframe contains NaN values, but if the same comparison is done for an individual column, it returns False.

Expected Output

It seems that returning False is more consistent with other data types.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.6.3
Cython: None
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@WillAyd
Copy link
Member

WillAyd commented Jan 11, 2019

Can you try on master? These were the same for me

@WillAyd WillAyd added the Needs Info Clarification about behavior needed to assess issue label Jan 11, 2019
@mroeschke
Copy link
Member

I am getting the correct values on master and I think this was closed by #22163 in 0.24.0

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