Answers for "python dataframe column unique values"

1

get list of unique values in pandas column

a = df['column name'].unique() #returns a list of unique values
Posted by: Guest on March-29-2021
0

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)
Posted by: Guest on October-20-2020

Code answers related to "python dataframe column unique values"

Python Answers by Framework

Browse Popular Code Answers by Language