how to get unique rows in pandas code example

Example 1: pandas unique values in column

#List unique values in the df['name'] column
df.name.unique()

Example 2: get list of unique values in pandas column

a = df['column name'].unique() #returns a list of unique values

Example 3: distinct rows in this DataFrame

# distinct rows in this DataFrame

df.distinct().count()
# 2

Example 4: dataframe number of unique rows

1
# get the unique values (rows) by retaining last row
2
df.drop_duplicates(keep='last')

Example 5: Returns a new DataFrame containing the distinct rows in this DataFrame

# Returns a new DataFrame containing the distinct rows in this DataFrame

df.ditinct().count()
# 2