Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas groupby column count distinct values

# Pandas group by a column looking at the count unique/count distinct values of another column

df.groupby('param')['group'].nunique()
Comment

pandas groupby count unique rows

df = df.groupby(by='domain', as_index=False).agg({'ID': pd.Series.nunique})
print(df)
    domain  ID
0       fb   1
1      ggl   1
2  twitter   2
3       vk   3
Comment

pandas groupby count unique rows

ID, domain
123, 'vk.com'
123, 'vk.com'
123, 'twitter.com'
456, 'vk.com'
456, 'facebook.com'
456, 'vk.com'
456, 'google.com'
789, 'twitter.com'
789, 'vk.com'
Comment

PREVIOUS NEXT
Code Example
Python :: pandas save without index 
Python :: print json python 
Python :: cv2.imwrite save to folder 
Python :: alphabet list python 
Python :: python keylogger 
Python :: convert json to x-www-form-urlencoded pyhon 
Python :: how to create dataframe in python 
Python :: python pyautogui how to change the screenshot location 
Python :: HOw to use passlock password manager python 
Python :: Counter to df pandas 
Python :: correlation between lists python 
Python :: numpy mean 2 arrays 
Python :: count missing values by column in pandas 
Python :: pytorch tensor add one dimension 
Python :: print current time hours and minutes in python 
Python :: python pil image flip 
Python :: python confidence interval 
Python :: size of variable python 
Python :: matplotlib add space between subplots 
Python :: bgr2gray opencv 
Python :: pandas series values into strings 
Python :: how to import image in python 
Python :: get files in directory python 
Python :: python run 2 functions at the same time 
Python :: python count the frequency of words in a list 
Python :: random word generator python 
Python :: how to set a image as background in tkitner 
Python :: anaconda python update packages 
Python :: create dataframe pyspark 
Python :: pandas has no attribute scatter_matrix 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =