Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get a bar plot with a condition

I want to plot a bar chart for a list of items. It is a list of string names with frequencies (int) The list is quite long, so I can not manually edit it.

[]                       4291017
['a']                    221943
['b']                    121027
['d']                    100915
['c']                    54344
['g']                    33486

The above was an output of the following command:
names = df[‘names’].explode().value_counts().head(N)

The plot command that I am using is:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

names.plot(kind='barh')

How can I plot it for all the values except for the first one, which is basically an empty field? The problem is that I cannot drop it as it is not NaN.

>Solution :

Quick and dirty:

names = df['names'].explode().value_counts().iloc[1:]

will remove the first line ([])

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading