Skip to content

Regression: cannot set a Timestamp with a non-timestamp #18660

Closed
@discort

Description

@discort

Code Sample, a copy-pastable example if possible

import pandas as pd
from datetime import datetime

dates = [pd.Timestamp('2012-01-01'), pd.Timestamp('2017-01-02'), pd.Timestamp('2017-01-03')]
df = pd.DataFrame({'dates': dates})
today = datetime.today().date()
print(df['dates'] == today)
Traceback (most recent call last):
  File "date_bug.py", line 22, in <module>
    main()
  File "date_bug.py", line 18, in main
    print(df['dates'] == today)
  File "/Users/discort/python/projects/pims/env/lib/python3.5/site-packages/pandas/core/ops.py", line 879, in wrapper
    res = na_op(values, other)
  File "/Users/discort/python/projects/pims/env/lib/python3.5/site-packages/pandas/core/ops.py", line 808, in na_op
    y = libindex.convert_scalar(x, _values_from_object(y))
  File "pandas/_libs/index.pyx", line 494, in pandas._libs.index.convert_scalar
  File "pandas/_libs/index.pyx", line 509, in pandas._libs.index.convert_scalar
ValueError: cannot set a Timestamp with a non-timestamp

Problem description

There is a regression. Related: #17965
On 0.18.1 it works fine

Expected Output

0    False
1    False
2    False
Name: dates, dtype: bool

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None

pandas: 0.21.0
pytest: 2.9.2
pip: 9.0.1
setuptools: 36.4.0
Cython: None
numpy: 1.13.3
scipy: None
pyarrow: None
xarray: None
IPython: 6.1.0
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
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: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions