Skip to content

TST: cover search_sorted scalar mixed timezones case #33185

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

Conversation

jamescobonkerr
Copy link
Contributor

Raises a ValueError on version 0.25.1 (reporter's version), as expected:

>>> import pandas as pd
>>> pd.__version__
'0.25.1'
>>> ser = pd.Series(date_range("20120101", periods=10, freq="2D", tz="UTC"))
>>> val = pd.Timestamp("20120102", tz="America/New_York")
>>> res = ser.searchsorted(val)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jamescobonkerr/venv/lib/python3.7/site-packages/pandas/core/series.py", line 2694, in searchsorted
    return algorithms.searchsorted(self._values, value, side=side, sorter=sorter)
  File "/Users/jamescobonkerr/venv/lib/python3.7/site-packages/pandas/core/algorithms.py", line 1887, in searchsorted
    result = arr.searchsorted(value, side=side, sorter=sorter)
  File "/Users/jamescobonkerr/venv/lib/python3.7/site-packages/pandas/core/arrays/datetimelike.py", line 666, in searchsorted
    self._check_compatible_with(value)
  File "/Users/jamescobonkerr/venv/lib/python3.7/site-packages/pandas/core/arrays/datetimes.py", line 591, in _check_compatible_with
    own=self.tz, other=other.tz
ValueError: Timezones don't match. 'UTC != America/New_York'

@jschendel jschendel added the Testing pandas testing functions or related to the test suite label Mar 31, 2020
@jschendel jschendel added this to the 1.1 milestone Mar 31, 2020
@jreback jreback added the Timezones Timezone data dtype label Mar 31, 2020
@jreback jreback merged commit 98a2aa3 into pandas-dev:master Mar 31, 2020
@jreback
Copy link
Contributor

jreback commented Mar 31, 2020

thanks @jamescobonkerr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series.searchsorted with different timezones
3 participants