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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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)