Skip to content

Commit 0a15674

Browse files
committed
CLN: move import, add whatsnew entry
1 parent c8844e0 commit 0a15674

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -886,3 +886,4 @@ Bug Fixes
886886
- Bug in ``pd.melt()`` where passing a tuple value for ``value_vars`` caused a ``TypeError`` (:issue:`15348`)
887887
- Bug in ``.eval()`` which caused multiline evals to fail with local variables not on the first line (:issue:`15342`)
888888
- Bug in ``pd.read_msgpack`` which did not allow to load dataframe with an index of type ``CategoricalIndex`` (:issue:`15487`)
889+
- Bug in ``groupby.apply()`` coercing ``object`` series to numeric types, when not all values were numeric (:issue:`15680`)

pandas/core/groupby.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
callable, map
1212
)
1313

14-
import pandas as pd
1514
from pandas import compat
1615
from pandas.compat.numpy import function as nv
1716
from pandas.compat.numpy import _np_version_under1p8
@@ -3426,6 +3425,7 @@ def _decide_output_index(self, output, labels):
34263425

34273426
def _wrap_applied_output(self, keys, values, not_indexed_same=False):
34283427
from pandas.core.index import _all_indexes_same
3428+
from pandas.tools.util import to_numeric
34293429

34303430
if len(keys) == 0:
34313431
return DataFrame(index=keys)
@@ -3569,7 +3569,7 @@ def first_non_None_value(values):
35693569
so = self._selected_obj
35703570
if (so.ndim == 2 and so.dtypes.apply(is_datetimelike).any()):
35713571
result = result.apply(
3572-
lambda x: pd.to_numeric(x, errors='ignore'))
3572+
lambda x: to_numeric(x, errors='ignore'))
35733573
date_cols = self._selected_obj.select_dtypes(
35743574
include=['datetime', 'timedelta']).columns
35753575
date_cols = date_cols.intersection(result.columns)

0 commit comments

Comments
 (0)