Bar graph does not work properly on pandas groupby object

I am trying to use the built-in methods for constructing pandas dataframe objects, but I am having problems with groupby. Note the following: this first section of code works as expected.

df = pd.DataFrame(np.random.randn(100,3), columns=['A', 'B', 'C'])
df['D'] = np.random.randint(0, 3, len(df))
df.A.plot(kind='hist', histtype='stepfilled')

Correctly interpreted bar chart

Now let's see what happens when I try it with a groupby object

dfg = df.groupby('D')
dfg.A.plot(kind='hist', histtype='stepfilled')    

Does not execute a histogram

The result is a standard schedule. He seems to have no options. When I try to use the .hist () method, it will not accept or process keywords.

 dfg.A.hist(histtype='stepfilled')

Doesn't go through keywords

Am I doing something wrong? Should I record a bug report? Or am I expecting something that is not meant to be provided?

+4
source share
1 answer

groupby :

df.A.plot(kind='hist', by='D', histtype='stepfilled')

- :

enter image description here

, , groupby , by. , .

-1

Source: https://habr.com/ru/post/1620150/


All Articles