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 do I create histograms for all variables except one in Python?

df.hist() gives you histograms for all variables.
df.hist(column='age') gives you a histogram for just age.

What if I want histograms for all variables except one? Do I have to do them separately? And what’s the difference between using df.hist() and the Matplotlib version anyway?

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

>Solution :

Save the column that you want to exclude in a variable:
exclude = ["age"]

And the plot the histogram accordingly:
df.loc[:, df.columns.difference(exclude)].hist(figsize=(15, 10));

This should solve your problem.

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