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 :: plot value counta 
Python :: best free rat for windows 
Python :: python fiscal year prior 
Python :: convert python pandas series dtype to datetime 
Python :: remove grid in plt 
Python :: python parse args 
Python :: get datatype of all columns pandas 
Python :: how to add numbers in python using for loop 
Python :: try datetime python 
Python :: seaborn styles 
Python :: python loop every month datetime 
Python :: rolling average df 
Python :: python httpserver 
Python :: python f string decimal places 
Python :: python read tab delimited file 
Python :: python series sort 
Python :: p-norm of a vector python 
Python :: python bisection method 
Python :: django load model by name 
Python :: import settings 
Python :: runner up score through recurssion 
Python :: talos get best model 
Python :: cut 0s on string python 
Python :: pandas get numeric columns 
Python :: python sympy solve equation equal to 0 
Python :: convert streamlit imageBytes = file.read() to image 
Python :: per gjera te shumta. Python 
Python :: Python USD to Euro Converter 
Python :: pypi toml 
Python :: browse list python 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =