question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pandas dtype Int64 not recognised as numeric in plot.box()

See original GitHub issue

Description

plot.box() fails with No numeric types to aggregate when using the pandas dtype Int64 in a dataframe. However, the standard dtype int64 works.

Example code

data = np.random.randint(1, 9, (10, 5))
df = pd.DataFrame(data, columns=['A', 'B', 'C', 'D', 'E'], dtype='Int64')
df.plot.box()

Traceback and Output

Cell output

DataError [Call holoviews.ipython.show_traceback() for details]
No numeric types to aggregate
Subsequent Traceback

Traceback (most recent call last):

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\holoviews\plotting\bokeh\element.py", line 1583, in _init_glyphs
    group_style = self._apply_transforms(element, ds_data, ranges, group_style, style_group)

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\holoviews\plotting\bokeh\stats.py", line 113, in _apply_transforms
    element = element.aggregate(function=np.mean)

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\holoviews\core\data\__init__.py", line 201, in pipelined_fn
    result = method_fn(*args, **kwargs)

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\holoviews\core\data\__init__.py", line 917, in aggregate
    aggregated, dropped = self.interface.aggregate(self, kdims, function, **kwargs)

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\holoviews\core\data\pandas.py", line 244, in aggregate
    df = grouped.aggregate(fn, **kwargs).reset_index()

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\pandas\core\groupby\generic.py", line 945, in aggregate
    result, how = aggregate(self, func, *args, **kwargs)

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\pandas\core\aggregation.py", line 577, in aggregate
    return getattr(obj, f)(), None

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\pandas\core\groupby\groupby.py", line 1496, in mean
    return self._cython_agg_general(

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\pandas\core\groupby\generic.py", line 1015, in _cython_agg_general
    agg_mgr = self._cython_agg_blocks(

  File "C:\Users\mydev\Miniconda3\envs\jlab3\lib\site-packages\pandas\core\groupby\generic.py", line 1114, in _cython_agg_blocks
    raise DataError("No numeric types to aggregate")

pandas.core.base.DataError: No numeric types to aggregate

Version info

conda env

Windows 10
- hvplot            0.7.0   
- python           3.8.6   
- pandas           1.2.1   
- numpy            1.19.5  
- bokeh             2.2.3   
- holoviews       1.14.1
- pyviz_comms  2.0.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, May 21, 2021

Appears to be fixed in pandas now.

0reactions
philippjfrcommented, Feb 2, 2021

Sure, but I can guarantee that users will have broken versions of Pandas for years to come.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas DataFrame "no numeric data to plot" error
I am still trying to learn plotting from within pandas . I want a plot In the above example when I say ....
Read more >
How to Fix in Pandas: TypeError: no numeric data to plot
This error occurs when you attempt to plot values from a pandas DataFrame, but there are no numeric values to plot. This error...
Read more >
10 tricks for converting Data to a Numeric Type in Pandas
The simplest way to convert data type from one to the other is to use astype() method. The method is supported by both...
Read more >
What's new in 1.4.0 (January 22, 2022) - Pandas
When using concat() to concatenate two or more DataFrame objects, if one of the DataFrames was empty or had all-NA values, its dtype...
Read more >
Pandas .values_count() & .plot() | Python Analysis Tutorial
Count the number of times a value occurs using .values_count(); Plot bar charts ... Universal Fund 151 Watsi | How Watsi works 93...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found