python subset dataframe based on unique value of a clumn

Solutions on MaxInterview for python subset dataframe based on unique value of a clumn by the best coders in the world

showing results for - "python subset dataframe based on unique value of a clumn"
Viktoria
21 Jun 2016
1# Keep first duplicate value
2my_df = my_df.drop_duplicates(subset=['my_var'])
3
4# Keep last duplicate value
5my_df = my_df.drop_duplicates(subset=['my_var'], keep='last')
6
7# Remove all duplicate values
8my_df = my_df.drop_duplicates(subset=['my_var'], keep=False)