Skip to content

Commit

Permalink
Merge branch 'master' into parquet-categorical
Browse files Browse the repository at this point in the history
* master: (22 commits)
  DOC: fix PR09,PR08 errors for pandas.Timestamp (#28739)
  WEB: Add diversity note to team.md (#28630)
  DOC: Minor fixes in pandas/testing.py docstring. (#28752)
  TST: port maybe_promote tests from #23982 (#28764)
  Bugfix/groupby datetime issue (#28569)
  reenable codecov (#28750)
  CLN: Centralised _check_percentile (#27584)
  DEPR: Deprecate Index.set_value (#28621)
  CLN: Fix typo in contributing.rst (#28761)
  Fixed docstring errors in pandas.period range and pandas.PeriodIndex (#28756)
  BUG: Fix TypeError raised in libreduction (#28643)
  DOC: Pandas.Series.drop docstring PR02 (#27976) (#28742)
  DOC: Fixed doctring errors PR08, PR09 in pandas.io (#28748)
  TST: Fix broken test cases where Timedelta/Timestamp raise (#28729)
  REF: Consolidate alignment calls in DataFrame ops (#28638)
  BUG: Fix dep generation (#28734)
  Added doctstring to fixture (#28727)
  DOC: Fixed PR06 docstrings errors in pandas.timedelta_range (#28719)
  replaced safe_import with a corresponding test decorator (#28731)
  BUG: Fix RangeIndex.get_indexer for decreasing RangeIndex (#28680)
  ...
  • Loading branch information
galuhsahid committed Oct 4, 2019
2 parents 4a6f6ad + ac39473 commit c02059d
Show file tree
Hide file tree
Showing 36 changed files with 635 additions and 341 deletions.
11 changes: 5 additions & 6 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ do
# 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
sh -c "$PYTEST_CMD; ret=\$?; [ \$ret = 5 ] && exit 0 || exit \$ret"

# 2019-08-21 disabling because this is hitting HTTP 400 errors GH#27602
# if [[ "$COVERAGE" && $? == 0 && "$TRAVIS_BRANCH" == "master" ]]; then
# echo "uploading coverage for $TYPE tests"
# echo "bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME"
# bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME
# fi
if [[ "$COVERAGE" && $? == 0 && "$TRAVIS_BRANCH" == "master" ]]; then
echo "uploading coverage for $TYPE tests"
echo "bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME"
bash <(curl -s https://codecov.io/bash) -Z -c -F $TYPE -f $COVERAGE_FNAME
fi
done
2 changes: 1 addition & 1 deletion doc/source/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ the expected correct result::
Transitioning to ``pytest``
~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

.. code-block:: python
Expand Down
1 change: 0 additions & 1 deletion doc/source/reference/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ Selecting
Index.get_slice_bound
Index.get_value
Index.get_values
Index.set_value
Index.isin
Index.slice_indexer
Index.slice_locs
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Indexing
^^^^^^^^

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

Expand Down
6 changes: 4 additions & 2 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ Documentation Improvements
Deprecations
~~~~~~~~~~~~

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

.. _whatsnew_1000.prior_deprecations:
Expand Down Expand Up @@ -190,7 +192,7 @@ Datetimelike
- Bug in :class:`Series` and :class:`DataFrame` with integer dtype failing to raise ``TypeError`` when adding or subtracting a ``np.datetime64`` object (:issue:`28080`)
- Bug in :class:`Week` with ``weekday`` incorrectly raising ``AttributeError`` instead of ``TypeError`` when adding or subtracting an invalid type (:issue:`28530`)
- Bug in :class:`DataFrame` arithmetic operations when operating with a :class:`Series` with dtype `'timedelta64[ns]'` (:issue:`28049`)
-
- 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`)

Timedelta
^^^^^^^^^
Expand Down
26 changes: 17 additions & 9 deletions pandas/_libs/reduction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ from numpy cimport (ndarray,
cnp.import_array()

cimport pandas._libs.util as util
from pandas._libs.lib import maybe_convert_objects, values_from_object
from pandas._libs.lib import maybe_convert_objects


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

if (util.is_array(obj) or
(isinstance(obj, list) and len(obj) == cnt) or
getattr(obj, 'shape', None) == (cnt,)):
raise ValueError('function does not reduce')
raise ValueError('Function does not reduce')

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

Expand Down Expand Up @@ -103,7 +103,7 @@ cdef class Reducer:
ndarray arr, result, chunk
Py_ssize_t i, incr
flatiter it
bint has_labels
bint has_labels, has_ndarray_labels
object res, name, labels, index
object cached_typ=None

Expand All @@ -113,14 +113,18 @@ cdef class Reducer:
chunk.data = arr.data
labels = self.labels
has_labels = labels is not None
has_ndarray_labels = util.is_array(labels)
has_index = self.index is not None
incr = self.increment

try:
for i in range(self.nresults):

if has_labels:
if has_ndarray_labels:
name = util.get_value_at(labels, i)
elif has_labels:
# labels is an ExtensionArray
name = labels[i]
else:
name = None

Expand Down Expand Up @@ -362,7 +366,8 @@ cdef class SeriesGrouper:

def get_result(self):
cdef:
ndarray arr, result
# Define result to avoid UnboundLocalError
ndarray arr, result = None
ndarray[int64_t] labels, counts
Py_ssize_t i, n, group_size, lab
object res
Expand Down Expand Up @@ -428,6 +433,9 @@ cdef class SeriesGrouper:
islider.reset()
vslider.reset()

if result is None:
raise ValueError("No result.")

if result.dtype == np.object_:
result = maybe_convert_objects(result)

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

if labels is not None:
if labels._has_complex_internals:
raise Exception('Cannot use shortcut')
# Caller is responsible for ensuring we don't have MultiIndex
assert not labels._has_complex_internals

# pass as an ndarray
labels = values_from_object(labels)
# pass as an ndarray/ExtensionArray
labels = labels._values

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

0 comments on commit c02059d

Please sign in to comment.