Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas dataframe limit rows by col value

# Reduce the DataFrame to Equal Count of Label Types
min = df.label.value_counts().min()
df = df.groupby('label').head(min).reset_index()
 
PREVIOUS NEXT
Tagged: #pandas #dataframe #limit #rows
ADD COMMENT
Topic
Name
5+8 =