Skip to content

BUG: DTI.searchsorted accepting invalid types/dtypes #30826

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

Merged
merged 2 commits into from
Jan 9, 2020

Conversation

jbrockmendel
Copy link
Member

Analogous to #30763 which fixed the same issue for PeriodIndex. After this will be a PR to fix TimedeltaIndex, then one to move the fixes up to the EA methods (and share searchsorted).

@jschendel
Copy link
Member

If a plain list is passed should there be an attempt to infer the dtype (or just coerce to an array-like) to determine if the list is valid? E.g. should the following succeed?

In [1]: import pandas as pd; pd.__version__
Out[1]: '0.26.0.dev0+1685.g9565b5666'

In [2]: dti = pd.date_range("2020", periods=3)

In [3]: dti.searchsorted(list(dti))
---------------------------------------------------------------------------
TypeError: searchsorted requires compatible dtype or scalar, not list

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Datetime Datetime data dtype labels Jan 9, 2020
@jreback jreback added this to the 1.0 milestone Jan 9, 2020
@jreback
Copy link
Contributor

jreback commented Jan 9, 2020

If a plain list is passed should there be an attempt to infer the dtype (or just coerce to an array-like) to determine if the list is valid? E.g. should the following succeed?

In [1]: import pandas as pd; pd.__version__
Out[1]: '0.26.0.dev0+1685.g9565b5666'

In [2]: dti = pd.date_range("2020", periods=3)

In [3]: dti.searchsorted(list(dti))
---------------------------------------------------------------------------
TypeError: searchsorted requires compatible dtype or scalar, not list

i suppose we could wrap list-likes with pa.array, but this would be an enhancement; can you open an issue.

@jreback jreback merged commit 5c12d4f into pandas-dev:master Jan 9, 2020
@jreback
Copy link
Contributor

jreback commented Jan 9, 2020

thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the ref-to_M8_2 branch January 9, 2020 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants