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

Pandas hist how to set bins by slice step

For example, there is a dataset of vacancies with salary mentioned, so I want to make a histogram showing the distribution of salaries by number of vacancies. I want to organise bins by regular steps, e.g. a new bin every 50000 "money". I can write them directly, like in documentation:
df['salary'].hist(bins=(50000, 100000, 150000, 200000, 250000)) and so on, but with dataset values up to 2000000 the line will be hell long. I think it would be elegant to organise bins using a slice step ([::x]), but I have no idea how.
Humbly asking the community for their ideas and insights.

>Solution :

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

what about bins=[bin for bin in range(0, 2000000, 50000)]

to calculate the max use

[bin for bin in range(0, df['salary'].max()+50000, 50000)]
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