Skip to content

Comparisons between datetime64[ns] #24087

Closed
@set92

Description

@set92

Code Sample, a copy-pastable example if possible

content of dataframe j
REFERENCIA FECHAPROGRAMA FECHAENVIO NECESIDAD
0 81007104 2015-04-04 2016-01-04 1038.0
1 81007104 2015-04-11 2016-01-04 1281.0
4 81007104 2015-04-18 2016-01-04 1172.0
...
1228 81007104 2015-12-05 2016-01-28 180.0
...
1541 81007104 2016-01-02 2016-01-29 180.0
1639 81007104 2016-01-09 2016-01-29 360.0
1734 81007104 2016-01-16 2016-01-29 360.0
1833 81007104 2016-01-23 2016-01-29 360.0

and the code is

a = j['FECHAENVIO'][-1:]
print(j['FECHAENVIO'][0] == a) #False 
print(j[j['FECHAENVIO'] == a]) #ValueError: Can only compare identically-labeled Series objects

Problem description

I have part of a dataframe groupby REFERENCIA, and now I wanted to get all rows with the last day in FECHAENVIO, for that I tried to get the last date in FECHAENVIO, save it in a, and then compare all the column with this date.

After checking SO and not able to find anything related to it, I found the issue #17965 and I think is relate to it, but not sure.

After 2 hours I did a workaround using FECHAENVIO as the index and using j.last('1D'), but I thought it was better to inform of the possible bug.

Expected Output

A dataframe with rows in which FECHAENVIO is equals to the variable a.

Output of pd.show_versions()

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

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

pandas: 0.23.4
pytest: 3.8.0
pip: 18.1
setuptools: 40.2.0
Cython: 0.28.5
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: 1.7.9
patsy: 0.5.0
dateutil: 2.7.5
pytz: 2018.5
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 2.2.3
openpyxl: 2.5.6
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.1.0
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.11
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions