Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas transform vs filter

# when used with groupby, transform is faster than filter
# use transform instead of filter e.g.
df = df[(df.groupby('col1')['col2'].transform('sum')>=200) 
        & (df.groupby('col1')['col3'].transform('nunique')>=20)]
Comment

PREVIOUS NEXT
Code Example
Python :: hide password in python 
Python :: how to if in pythob 
Python :: python xgboost 
Python :: python true and false 
Python :: Math Module floor() Function in python 
Python :: python how to add 2 numbers 
Python :: axes_style seaborn 
Python :: change version of python that poetry use 
Python :: Python match.re and match.string 
Python :: email validation using django 
Python :: odd number in python 
Python :: python array drop item 
Python :: python loop over list 
Python :: python for print 
Python :: add in python 
Python :: how to create Varible in python 
Python :: coding 
Python :: editing specific line in text file in python 
Python :: optimize python code 
Python :: how to print the 3erd character of an input in python 
Python :: This code is supposed to display "2 + 2 = 4" on the screen, but there is an error. Find the error in the code and fix it, so that the output is correct. 
Python :: Python controller input 
Python :: Return an RDD with the keys of each tuple. 
Python :: john cabot 
Python :: python togli spazio 
Python :: make a effective figure in python 
Shell :: classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap 
Shell :: ubuntu remove kite 
Shell :: update google chrome command ubuntu 
Shell :: git set email for project 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =