Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

nunique sort

df = df.groupby('A')['B'].nunique().sort_values(ascending=False).reset_index(name='count')
print (df)
   A  count
0  D      3
1  C      2
2  E      1
Comment

PREVIOUS NEXT
Code Example
Python :: populate initial data for django simple history 
Python :: pls work 
Python :: turtle meaning 
Python :: reading json without using relative path in django 
Python :: pandas data frame from part of excel openpyxl 
Python :: example of a simple function that takes in parameters in python 
Python :: pip install rejson 
Python :: blakyubeuiwbciwcqiby7ib.py 
Python :: Value Error handling 
Python :: adding the first place value and second value in python 
Python :: save datetime day in seperate column 
Python :: aw mustard 
Python :: branchless if python 
Python :: python format inverse 
Python :: /var/www/html/flag 
Python :: how can i get the data from a queryset in django template 
Python :: pandas subtract two columns 
Python :: use python logging to log user ips+time in a file whenever a request comes to the server, this should be done in a custom middleware. 
Python :: How to add an item from another set or other data structures (lists, dictionaries, and tuples) to a set by using the update() method. 
Python :: Display summary of all the numerical variables in the DataFrame 
Python :: how to scale numbers between -1 and 1 python 
Python :: python equivalent linkedhashmap 
Python :: Create Admin Interface For Objects 
Python :: python async get result 
Python :: using django annotations to get the last record 
Python :: packing a tuple 
Python :: geopandas bbox 
Python :: djangorestframework install command 
Python :: Source Code: Check Armstrong number (for 3 digits) 
Python :: redirect user based on input with python cgi code 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =