Closed
Description
Hello,
this code works fine:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
bins = np.arange(80, 100 + 2, 1)
df = pd.DataFrame({"Name": ["AAA", "BBB"], "ByCol": [1, 2], "Mark": [85, 89]})
df
ByCol Mark Name
0 1 85 AAA
1 2 89 BBB
df["Mark"].hist(by=df["ByCol"], bins=bins)
plt.show()
but same code with a one row DataFrame such as
df = pd.DataFrame({"Name": ["AAA"], "ByCol": [1], "Mark": [85]})
df
ByCol Mark Name
0 1 85 AAA
raises:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-35-93bcd47d24f2> in <module>()
----> 1 df["Mark"].hist(by=df["Mark"], bins=bins)
//anaconda/lib/python2.7/site-packages/pandas/tools/plotting.pyc in hist_series(self, by, ax, grid, xlabelsize, xrot, ylabelsize, yrot, figsize, bins, **kwds)
2847 **kwds)
2848
-> 2849 if axes.ndim == 1 and len(axes) == 1:
2850 return axes[0]
2851 return axes
AttributeError: 'AxesSubplot' object has no attribute 'ndim'
Kind regards