Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python - subset dataframe based on unique value of a clumn

# Keep first duplicate value
my_df = my_df.drop_duplicates(subset=['my_var'])

# Keep last duplicate value
my_df = my_df.drop_duplicates(subset=['my_var'], keep='last')

# Remove all duplicate values
my_df = my_df.drop_duplicates(subset=['my_var'], keep=False)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #subset #dataframe #based #unique #clumn
ADD COMMENT
Topic
Name
1+2 =