Python Forum
How to get count of each unique item in dataframe
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get count of each unique item in dataframe
#4
It beats me why one want to do that but little modification of scidam solution will do:

>>> new = pd.DataFrame(df.Age.value_counts()).rename_axis(columns='Labels').rename(columns={'Age':'values'})
>>> new
Labels  values
Fail         2
Pass         2
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: How to get count of each unique item in dataframe - by perfringo - Aug-05-2019, 05:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get first and last row index of each unique names in pandas dataframe SriRajesh 1 4,555 Oct-13-2018, 07:04 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020