python - subset dataframe based on unique value of a clumn code example
Example: 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)