Skip to content

Commit c02059d

Browse files
committed
Merge branch 'master' into parquet-categorical
* master: (22 commits) DOC: fix PR09,PR08 errors for pandas.Timestamp (pandas-dev#28739) WEB: Add diversity note to team.md (pandas-dev#28630) DOC: Minor fixes in pandas/testing.py docstring. (pandas-dev#28752) TST: port maybe_promote tests from pandas-dev#23982 (pandas-dev#28764) Bugfix/groupby datetime issue (pandas-dev#28569) reenable codecov (pandas-dev#28750) CLN: Centralised _check_percentile (pandas-dev#27584) DEPR: Deprecate Index.set_value (pandas-dev#28621) CLN: Fix typo in contributing.rst (pandas-dev#28761) Fixed docstring errors in pandas.period range and pandas.PeriodIndex (pandas-dev#28756) BUG: Fix TypeError raised in libreduction (pandas-dev#28643) DOC: Pandas.Series.drop docstring PR02 (pandas-dev#27976) (pandas-dev#28742) DOC: Fixed doctring errors PR08, PR09 in pandas.io (pandas-dev#28748) TST: Fix broken test cases where Timedelta/Timestamp raise (pandas-dev#28729) REF: Consolidate alignment calls in DataFrame ops (pandas-dev#28638) BUG: Fix dep generation (pandas-dev#28734) Added doctstring to fixture (pandas-dev#28727) DOC: Fixed PR06 docstrings errors in pandas.timedelta_range (pandas-dev#28719) replaced safe_import with a corresponding test decorator (pandas-dev#28731) BUG: Fix RangeIndex.get_indexer for decreasing RangeIndex (pandas-dev#28680) ...
2 parents 4a6f6ad + ac39473 commit c02059d

36 files changed

+635
-341
lines changed

ci/run_tests.sh

+5-6
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ do
4343
# if no tests are found (the case of "single and slow"), pytest exits with code 5, and would make the script fail, if not for the below code
4444
sh -c "$PYTEST_CMD; ret=\$?; [ \$ret = 5 ] && exit 0 || exit \$ret"
4545

46-
# 2019-08-21 disabling because this is hitting HTTP 400 errors GH#27602
47-
# if [[ "$COVERAGE" && $? == 0 && "$TRAVIS_BRANCH" == "master" ]]; then
48-
# echo "uploading coverage for $TYPE tests"
49-
# echo "bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME"
50-
# bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME
51-
# fi
46+
if [[ "$COVERAGE" && $? == 0 && "$TRAVIS_BRANCH" == "master" ]]; then
47+
echo "uploading coverage for $TYPE tests"
48+
echo "bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME"
49+
bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME
50+
fi
5251
done

doc/source/development/contributing.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ the expected correct result::
952952
Transitioning to ``pytest``
953953
~~~~~~~~~~~~~~~~~~~~~~~~~~~
954954

955-
*pandas* existing test structure is *mostly* classed based, meaning that you will typically find tests wrapped in a class.
955+
*pandas* existing test structure is *mostly* class-based, meaning that you will typically find tests wrapped in a class.
956956

957957
.. code-block:: python
958958

doc/source/reference/indexing.rst

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ Selecting
166166
Index.get_slice_bound
167167
Index.get_value
168168
Index.get_values
169-
Index.set_value
170169
Index.isin
171170
Index.slice_indexer
172171
Index.slice_locs

doc/source/whatsnew/v0.25.2.rst

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Indexing
5050
^^^^^^^^
5151

5252
- Fix regression in :meth:`DataFrame.reindex` not following ``limit`` argument (:issue:`28631`).
53+
- Fix regression in :meth:`RangeIndex.get_indexer` for decreasing :class:`RangeIndex` where target values may be improperly identified as missing/present (:issue:`28678`)
5354
-
5455
-
5556

doc/source/whatsnew/v1.0.0.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ Documentation Improvements
123123
Deprecations
124124
~~~~~~~~~~~~
125125

126-
-
126+
- ``Index.set_value`` has been deprecated. For a given index ``idx``, array ``arr``,
127+
value in ``idx`` of ``idx_val`` and a new value of ``val``, ``idx.set_value(arr, idx_val, val)``
128+
is equivalent to ``arr[idx.get_loc(idx_val)] = val``, which should be used instead (:issue:`28621`).
127129
-
128130

129131
.. _whatsnew_1000.prior_deprecations:
@@ -190,7 +192,7 @@ Datetimelike
190192
- Bug in :class:`Series` and :class:`DataFrame` with integer dtype failing to raise ``TypeError`` when adding or subtracting a ``np.datetime64`` object (:issue:`28080`)
191193
- Bug in :class:`Week` with ``weekday`` incorrectly raising ``AttributeError`` instead of ``TypeError`` when adding or subtracting an invalid type (:issue:`28530`)
192194
- Bug in :class:`DataFrame` arithmetic operations when operating with a :class:`Series` with dtype `'timedelta64[ns]'` (:issue:`28049`)
193-
-
195+
- Bug in :func:`pandas.core.groupby.generic.SeriesGroupBy.apply` raising ``ValueError`` when a column in the original DataFrame is a datetime and the column labels are not standard integers (:issue:`28247`)
194196

195197
Timedelta
196198
^^^^^^^^^

pandas/_libs/reduction.pyx

+17-9
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ from numpy cimport (ndarray,
1515
cnp.import_array()
1616

1717
cimport pandas._libs.util as util
18-
from pandas._libs.lib import maybe_convert_objects, values_from_object
18+
from pandas._libs.lib import maybe_convert_objects
1919

2020

2121
cdef _get_result_array(object obj, Py_ssize_t size, Py_ssize_t cnt):
2222

2323
if (util.is_array(obj) or
2424
(isinstance(obj, list) and len(obj) == cnt) or
2525
getattr(obj, 'shape', None) == (cnt,)):
26-
raise ValueError('function does not reduce')
26+
raise ValueError('Function does not reduce')
2727

2828
return np.empty(size, dtype='O')
2929

@@ -103,7 +103,7 @@ cdef class Reducer:
103103
ndarray arr, result, chunk
104104
Py_ssize_t i, incr
105105
flatiter it
106-
bint has_labels
106+
bint has_labels, has_ndarray_labels
107107
object res, name, labels, index
108108
object cached_typ=None
109109

@@ -113,14 +113,18 @@ cdef class Reducer:
113113
chunk.data = arr.data
114114
labels = self.labels
115115
has_labels = labels is not None
116+
has_ndarray_labels = util.is_array(labels)
116117
has_index = self.index is not None
117118
incr = self.increment
118119

119120
try:
120121
for i in range(self.nresults):
121122

122-
if has_labels:
123+
if has_ndarray_labels:
123124
name = util.get_value_at(labels, i)
125+
elif has_labels:
126+
# labels is an ExtensionArray
127+
name = labels[i]
124128
else:
125129
name = None
126130

@@ -362,7 +366,8 @@ cdef class SeriesGrouper:
362366

363367
def get_result(self):
364368
cdef:
365-
ndarray arr, result
369+
# Define result to avoid UnboundLocalError
370+
ndarray arr, result = None
366371
ndarray[int64_t] labels, counts
367372
Py_ssize_t i, n, group_size, lab
368373
object res
@@ -428,6 +433,9 @@ cdef class SeriesGrouper:
428433
islider.reset()
429434
vslider.reset()
430435

436+
if result is None:
437+
raise ValueError("No result.")
438+
431439
if result.dtype == np.object_:
432440
result = maybe_convert_objects(result)
433441

@@ -639,11 +647,11 @@ def compute_reduction(arr, f, axis=0, dummy=None, labels=None):
639647
"""
640648

641649
if labels is not None:
642-
if labels._has_complex_internals:
643-
raise Exception('Cannot use shortcut')
650+
# Caller is responsible for ensuring we don't have MultiIndex
651+
assert not labels._has_complex_internals
644652

645-
# pass as an ndarray
646-
labels = values_from_object(labels)
653+
# pass as an ndarray/ExtensionArray
654+
labels = labels._values
647655

648656
reducer = Reducer(arr, f, axis=axis, dummy=dummy, labels=labels)
649657
return reducer.get_result()

0 commit comments

Comments
 (0)