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

sort and count values in a column DataFrame (Python Pandas)

I have the next DataFrame

df

enter image description here

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

I count the values this way

enter image description here

I want to have the category values in the next order:

1.0 1

4.0 1

7.0 2

10.0 1

and so on …

In the ascending way with their respect amount of values

>Solution :

You can sort by index using sort_index()

df['col_1'].value_counts().sort_index()
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