Answers for "how to get unique entries of column in python"

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

how to get unique value of all columns in pandas

print(df.apply(lambda col: col.unique()))
Posted by: Guest on August-05-2021
0

pandas get column values distinct

import pandas as pd

colors = {'color': ['green', 'blue', 'blue', 'red', 'green']}
df = pd.DataFrame.from_dict(colors)

print(df['color'].unique())
Posted by: Guest on August-31-2021
0

dataframe python unique values rows

# get the unique values (rows)
df.drop_duplicates()
Posted by: Guest on June-03-2020
1

unique entries in column pandas

# Import modules
import pandas as pd

# Set ipython's max row display
pd.set_option('display.max_row', 1000)

# Set iPython's max column width to 50
pd.set_option('display.max_columns', 50)
# Create an example dataframe
data = {'name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 
        'year': [2012, 2012, 2013, 2014, 2014], 
        'reports': [4, 24, 31, 2, 3]}
df = pd.DataFrame(data, index = ['Cochice', 'Pima', 'Santa Cruz', 'Maricopa', 'Yuma'])
df

#List unique values in the df['name'] column
df.name.unique()
Posted by: Guest on June-29-2020

Code answers related to "how to get unique entries of column in python"

Python Answers by Framework

Browse Popular Code Answers by Language