Skip to content

TST: cover search_sorted scalar mixed timezones case#33185

Merged
jreback merged 3 commits into
pandas-dev:masterfrom
jamescobonkerr:series-searchsorted-mixed-timezones
Mar 31, 2020
Merged

TST: cover search_sorted scalar mixed timezones case#33185
jreback merged 3 commits into
pandas-dev:masterfrom
jamescobonkerr:series-searchsorted-mixed-timezones

Conversation

@jamescobonkerr

Copy link
Copy Markdown
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
Comment thread pandas/tests/series/methods/test_searchsorted.py
@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

jreback commented Mar 31, 2020

Copy link
Copy Markdown
Contributor

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