Dataframe: Empty 'Dataframe': no Numeric data to Plot

Asked

Viewed 383 times

0

I’m trying to get the highest values in the column Valor Pago. No Jupyter.

top_10_empenho = portal[['Descrição', 'Valor Pago']].head(10).set_index('Descrição').sort_values('Valor Pago', ascending=True)
top_10_empenho.plot(kind='barh', figsize=(11,7), grid=False, color='darkred', legend=False)
plt.title('teste1')
plt.xlabel('teste2')
plt.show()

But the following message appears.


TypeError                                 Traceback (most recent call last)
<ipython-input-96-6a6f04dd7619> in <module>
      1 #Os 10 Empenhos com Maior Valor Liquido
      2 top_10_empenho = portal[['Descrição', 'Valor Pago']].head(10).set_index('Descrição').sort_values('Valor Pago', ascending=True)
----> 3 top_10_empenho.plot(kind='barh', figsize=(11,7), grid=False, color='darkred', legend=False)
      4 
      5 plt.title('teste1')

~/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   2940                           fontsize=fontsize, colormap=colormap, table=table,
   2941                           yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2942                           sort_columns=sort_columns, **kwds)
   2943     __call__.__doc__ = plot_frame.__doc__
   2944 

~/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   1971                  yerr=yerr, xerr=xerr,
   1972                  secondary_y=secondary_y, sort_columns=sort_columns,
-> 1973                  **kwds)
   1974 
   1975 

~/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
   1799         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   1800 
-> 1801     plot_obj.generate()
   1802     plot_obj.draw()
   1803     return plot_obj.result

~/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py in generate(self)
    247     def generate(self):
    248         self._args_adjust()
--> 249         self._compute_plot_data()
    250         self._setup_subplots()
    251         self._make_plot()

~/anaconda3/lib/python3.7/site-packages/pandas/plotting/_core.py in _compute_plot_data(self)
    365         if is_empty:
    366             raise TypeError('Empty {0!r}: no numeric data to '
--> 367                             'plot'.format(numeric_data.__class__.__name__))
    368 
    369         self.data = numeric_data

TypeError: Empty 'DataFrame': no numeric data to plot

  • Try to do : top_10_commitment['Paid Amount']. Plot(Kind='barh', ...)

  • @Leonardobohac, face like this works well. But you know how to tell me to have together the column "Description"? Because when I put it like this: portal[["Description", "Value Paid"]]. head(20).plot.bar() --- Error reappears | Typeerror: Empty 'Dataframe': no Numeric data to Plot |

  • I think it’s because you want to put in the same Plot (in the same Plot call) two different data types (I imagine the "description" field is not numerical. You may be able to display both by placing the same code on the bottom line, but with top_10_effort[Description']. Plot(...).

  • @Leonardobohac, Type description are the names of natural and legal entities and value paid are the tastes values. Wanted to display in the chart the Entity followed by its value spent. When I place the two rows is not displayed the values of column paid value. portal["Valor Pago"].head(20).value_counts().sort_values().plot.bar()&#xA;portal["Descrição"].head(20).value_counts().sort_values().plot.bar()&#xA;#Definido Títulos&#xA;plt.title('As 10 Primeiras entidades')&#xA;plt.xlabel('Entidades')&#xA;plt.ylabel('Quant de Empenhos lançados')&#xA;plt.show()

  • You know the library matplotlib ? It is good to handle Plots instead of directly using the pandas plotting library.

  • @Leonardobohac, No! But I will try to search to replace my call to the chart.

  • Hello! Be able to join the columns using the function Crosstab. The code went like this: cruztab_dv = pd.crosstab(portal['Valor Pago'], portal['Descrição'])&#xA;cruztab_dv.head(). Even more not being able to display a chart.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.