Skip to content

Commit 8fe9f69

Browse files
Merge remote-tracking branch 'upstream/master' into skip_if_no
2 parents 85b8c63 + cf25c5c commit 8fe9f69

File tree

17 files changed

+80
-23
lines changed

17 files changed

+80
-23
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://pandas.pydata.org/donate.html

asv_bench/benchmarks/index_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def time_get_loc(self):
188188

189189
class IntervalIndexMethod:
190190
# GH 24813
191-
params = [10**3, 10**5, 10**7]
191+
params = [10**3, 10**5]
192192

193193
def setup(self, N):
194194
left = np.append(np.arange(N), np.array(0))

ci/deps/travis-36-cov.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ dependencies:
2020
# https://github.com/pydata/pandas-gbq/issues/271
2121
- google-cloud-bigquery<=1.11
2222
- psycopg2
23-
- pyarrow=0.9.0
23+
# pyarrow segfaults on load: https://github.com/pandas-dev/pandas/issues/26716
24+
# - pyarrow=0.9.0
2425
- pymysql
2526
- pytables
2627
- python-snappy

ci/deps/travis-36-doc.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ dependencies:
3333
- pytz
3434
- scipy
3535
- seaborn
36-
- sphinx
36+
# recursion error with sphinx 2.1.0. https://github.com/pandas-dev/pandas/issues/26723
37+
- sphinx==2.0.1
3738
- sqlalchemy
3839
- statsmodels
3940
- xarray

doc/source/whatsnew/v0.25.0.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ Performance Improvements
513513
- Improved performance of :meth:`IntervalIndex.intersection` (:issue:`24813`)
514514
- Improved performance of :meth:`read_csv` by faster concatenating date columns without extra conversion to string for integer/float zero and float ``NaN``; by faster checking the string for the possibility of being a date (:issue:`25754`)
515515
- Improved performance of :attr:`IntervalIndex.is_unique` by removing conversion to ``MultiIndex`` (:issue:`24813`)
516+
- Restored performance of :meth:`DatetimeIndex.__iter__` by re-enabling specialized code path (:issue:`26702`)
516517

517518
.. _whatsnew_0250.bug_fixes:
518519

@@ -539,13 +540,15 @@ Datetimelike
539540
- Bug in adding :class:`DateOffset` with nonzero month to :class:`DatetimeIndex` would raise ``ValueError`` (:issue:`26258`)
540541
- Bug in :func:`to_datetime` which raises unhandled ``OverflowError`` when called with mix of invalid dates and ``NaN`` values with ``format='%Y%m%d'`` and ``error='coerce'`` (:issue:`25512`)
541542
- Bug in :func:`to_datetime` which raises ``TypeError`` for ``format='%Y%m%d'`` when called for invalid integer dates with length >= 6 digits with ``errors='ignore'``
543+
- Bug when comparing a :class:`PeriodIndex` against a zero-dimensional numpy array (:issue:`26689`)
542544

543545
Timedelta
544546
^^^^^^^^^
545547

546548
- Bug in :func:`TimedeltaIndex.intersection` where for non-monotonic indices in some cases an empty ``Index`` was returned when in fact an intersection existed (:issue:`25913`)
547549
- Bug with comparisons between :class:`Timedelta` and ``NaT`` raising ``TypeError`` (:issue:`26039`)
548550
- Bug when adding or subtracting a :class:`BusinessHour` to a :class:`Timestamp` with the resulting time landing in a following or prior day respectively (:issue:`26381`)
551+
- Bug when comparing a :class:`TimedeltaIndex` against a zero-dimensional numpy array (:issue:`26689`)
549552

550553
Timezones
551554
^^^^^^^^^

environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ dependencies:
1616
- cython>=0.28.2
1717

1818
# code checks
19+
- cpplint
1920
- flake8
2021
- flake8-comprehensions # used by flake8, linting of unnecessary comprehensions
2122
- flake8-rst>=0.6.0,<=0.7.0 # linting of code blocks in rst files
2223
- isort # check that imports are in the right order
2324
- mypy
2425
- pycodestyle # used by flake8
25-
- pip:
26-
- cpplint
2726

2827
# documentation
2928
- gitpython # obtain contributors from git for whatsnew

pandas/core/arrays/period.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import numpy as np
66

7+
from pandas._libs import lib
78
from pandas._libs.tslibs import (
89
NaT, NaTType, frequencies as libfrequencies, iNaT, period as libperiod)
910
from pandas._libs.tslibs.fields import isleapyear_arr
@@ -51,6 +52,7 @@ def _period_array_cmp(cls, op):
5152
def wrapper(self, other):
5253
op = getattr(self.asi8, opname)
5354

55+
other = lib.item_from_zerodim(other)
5456
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
5557
return NotImplemented
5658

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def _td_array_cmp(cls, op):
6262
nat_result = opname == '__ne__'
6363

6464
def wrapper(self, other):
65+
other = lib.item_from_zerodim(other)
6566
if isinstance(other, (ABCDataFrame, ABCSeries, ABCIndexClass)):
6667
return NotImplemented
6768

pandas/core/indexes/datetimes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ def _join_i8_wrapper(joinf, **kwargs):
243243
_is_numeric_dtype = False
244244
_infer_as_myclass = True
245245

246+
# Use faster implementation given we know we have DatetimeArrays
247+
__iter__ = DatetimeArray.__iter__
246248
# some things like freq inference make use of these attributes.
247249
_bool_ops = DatetimeArray._bool_ops
248250
_object_ops = DatetimeArray._object_ops

pandas/core/indexes/range.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,9 @@ def __contains__(self, key: Union[int, np.integer]) -> bool:
346346
@Appender(_index_shared_docs['get_loc'])
347347
def get_loc(self, key, method=None, tolerance=None):
348348
if is_integer(key) and method is None and tolerance is None:
349+
new_key = int(key)
349350
try:
350-
return self._range.index(key)
351+
return self._range.index(new_key)
351352
except ValueError:
352353
raise KeyError(key)
353354
return super().get_loc(key, method=method, tolerance=tolerance)
@@ -608,19 +609,15 @@ def __getitem__(self, key):
608609
"""
609610
Conserve RangeIndex type for scalar and slice keys.
610611
"""
611-
super_getitem = super().__getitem__
612-
613612
if is_scalar(key):
614613
if not lib.is_integer(key):
615614
raise IndexError("only integers, slices (`:`), "
616615
"ellipsis (`...`), numpy.newaxis (`None`) "
617616
"and integer or boolean "
618617
"arrays are valid indices")
619-
n = com.cast_scalar_indexer(key)
620-
if n != key:
621-
return super_getitem(key)
618+
new_key = int(key)
622619
try:
623-
return self._range[key]
620+
return self._range[new_key]
624621
except IndexError:
625622
raise IndexError("index {key} is out of bounds for axis 0 "
626623
"with size {size}".format(key=key,
@@ -630,7 +627,7 @@ def __getitem__(self, key):
630627
return self.from_range(new_range, name=self.name)
631628

632629
# fall back to Int64Index
633-
return super_getitem(key)
630+
return super().__getitem__(key)
634631

635632
def __floordiv__(self, other):
636633
if isinstance(other, (ABCSeries, ABCDataFrame)):

0 commit comments

Comments
 (0)