get all rows with unique column value pandas code example
Example 1: pandas unique values in column
#List unique values in the df['name'] column
df.name.unique()
Example 2: 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)