X Tutup
Skip to content

ValueError when plotting Pandas Dataframe Summary #7943

@bidhya

Description

@bidhya

Bug report

Bug summary

  • Matplotlib gives this value error whenever plotting the summary statistics of Pandas DataFrame. The error started upon upgrading to Matplotlib 2.0, and it was working properly with older version 1.5. The code also works properly when plotting with pandas directly.

Code for reproduction

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame(
    np.random.randint(0, 100, size=(100, 3)),
    columns=["x", "y", "z"])
fig, ax = plt.subplots()
ax.plot(df.mean())
plt.show()

Actual outcome

# If applicable, paste the console output here
#
#
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-40-39e30c8ef428> in <module>()
      1 # plt.plot(X_train.mean())
----> 2 plt.plot(df.mean())

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\pyplot.pyc in plot(*args, **kwargs)
   3316                       mplDeprecation)
   3317     try:
-> 3318         ret = ax.plot(*args, **kwargs)
   3319     finally:
   3320         ax._hold = washold

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\__init__.pyc in inner(ax, *args, **kwargs)
   1889                     warnings.warn(msg % (label_namer, func.__name__),
   1890                                   RuntimeWarning, stacklevel=2)
-> 1891             return func(ax, *args, **kwargs)
   1892         pre_doc = inner.__doc__
   1893         if pre_doc is None:

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\axes\_axes.pyc in plot(self, *args, **kwargs)
   1405 
   1406         for line in self._get_lines(*args, **kwargs):
-> 1407             self.add_line(line)
   1408             lines.append(line)
   1409 

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\axes\_base.pyc in add_line(self, line)
   1785             line.set_clip_path(self.patch)
   1786 
-> 1787         self._update_line_limits(line)
   1788         if not line.get_label():
   1789             line.set_label('_line%d' % len(self.lines))

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\axes\_base.pyc in _update_line_limits(self, line)
   1807         Figures out the data limit of the given line, updating self.dataLim.
   1808         """
-> 1809         path = line.get_path()
   1810         if path.vertices.size == 0:
   1811             return

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\lines.pyc in get_path(self)
    987         """
    988         if self._invalidy or self._invalidx:
--> 989             self.recache()
    990         return self._path
    991 

C:\Users\bny\Anaconda2\lib\site-packages\matplotlib\lines.pyc in recache(self, always)
    674                 x = ma.asarray(xconv, np.float_).filled(np.nan)
    675             else:
--> 676                 x = np.asarray(xconv, np.float_)
    677             x = x.ravel()
    678         else:

C:\Users\bny\Anaconda2\lib\site-packages\numpy\core\numeric.pyc in asarray(a, dtype, order)
    480 
    481     """
--> 482     return array(a, dtype, copy=False, order=order)
    483 
    484 def asanyarray(a, dtype=None, order=None):

ValueError: could not convert string to float: basin_slope

Expected outcome
Just make the plot
It used to work on Matplotlib 1.5

Matplotlib version
Matplotlib: 2.0.0
Python : 2.7 32bit version
System: Windows10
Python and all packages installed with Anaconda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup