+ 2

counting unique values in DataFrame pandas

Series.value_counts(normalize=False, sort=True, ascending=False, bins=None, dropna=True) If sort=True, means descending order and ascending=False, means descending order then why both attributes are there ? Is there any special usecase ?

23rd Apr 2020, 5:37 PM
harshit
harshit - avatar
5 odpowiedzi
+ 3
From what I'm understand of the official documentation: 'sort' handle sort result by frequencies 'ascending' handle sort result by values That's a slightly difference, but would explains why two different "attributes" (more correct to call them "arguments" ;)) https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.value_counts.html
25th Apr 2020, 5:08 AM
visph
visph - avatar
+ 3
I think there is an attribute for ascending order, so that you don't need need to additionally reverse the list to get the list in ascending order. This is particularly useful when you are working with a large set of data. Otherwise you would additionally need to flip the list after sorting, which will be less efficient.
24th Apr 2020, 6:42 AM
Ishmam
Ishmam - avatar
+ 3
hm... did not notice the thing before. Seems like sort=True and ascending=True both sorts the series. Actually i am not that experienced with pandas.
24th Apr 2020, 9:57 AM
Ishmam
Ishmam - avatar
+ 2
Pluto{^_^} please see this
23rd Apr 2020, 10:44 PM
harshit
harshit - avatar
+ 2
Pluto{^_^} but sort = False, will automatically make it in ascending order.
24th Apr 2020, 9:23 AM
harshit
harshit - avatar