![]() ![]() usr/lib/python2.7/site-packages/pandas/core/groupby. an function call dispatches to self. > 1417 new_blocks = self._cython_agg_blocks(how, numeric_only=numeric_only)ġ418 return self._wrap_agged_blocks(new_blocks) usr/lib/python2.7/site-packages/pandas/core/groupby.py in _cython_agg_general(self, how, numeric_only)ġ416 def _cython_agg_general(self, how, numeric_only=True): > 297 return self._cython_agg_general('mean') For example: df.tenure df.tenure.astype (int) Share Improve this answer Follow answered at 4:21 DYZ 54. You must convert 'numeric' columns into numeric columns with. Some, but not all, aggregation methods can be computed locally and then can be re-aggregated to yield an accurate globally-aggregated result. Note: Not all aggregation types are supported when calculating aggregated results across multiple local domains. The no numeric types to aggregate error can be resolved using Pandas < 0.9 or explicitly specifying the float type for the DataFrame. usr/lib/python2.7/site-packages/pandas/core/groupby.py in mean(self) Sorted by: 3 All your columns, even those that look like numbers, are strings. The following table describes the supported aggregation types. In : data.T.groupby(lat_bucket).mean()ĭataError Traceback (most recent call last) In : lat_bucket = lambda x: _get_gridbox_label(x, latedges, lats_new) In : def _get_gridbox_label(x, bins, labels): On 0.9, I get No numeric types to aggregate errors. I have a problem with some groupy code which I'm quite sure once ran (on an older pandas version). You can aggregate non-numeric types, using first () and similar methods at /pandas-docs/stable/userguide/ The error message triggers specifically when trying to do a numeric aggregation, e.g. I got this done by : data_oupby(COL1).COL2.apply(np.mean).reset_index() I got this error generating a data frame consisting of timestamps and data: df = pd.DataFrame(, index=pd.DatetimeIndex(timestamp), dtype=float)) You can also call frame.astype(float) Solution 2 )) as pt In older versions, you can do below: select t.ID, min (case t.Label when 'a' then value end) as Label a, min (case t.Label when 'b' then value end) as Label b. from tbl as t pivot (min (t.value) for t.Label in (,. ![]() If so you can change the initialization to DataFrame(dtype=float). In SQL Server 2005, you can use the PIVOT operator like: select pt.ID, pt. In : dataĭatetimeIndex: 2557 entries, 00:00:00 to 00:00:00ĭid you initialize an empty DataFrame first and then filled it? If so that's probably why it changed with the new version as before 0.9 empty DataFrames were initialized to float type but now they are of object type. See how the output shows that your data is of 'object' type? the groupby operations specifically check whether each column is a numeric dtype first. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |