9951 explained code solutions for 126 technologies


python-pandasHow to get unique values from data frame column


import pandas as pd

df = pd.DataFrame({
  'type': ['A', 'A', 'A', 'B', 'B', 'C'],
  'age': [1, 3, 6, 3, 4, 1]
})

uniq_vals = df.type.unique()ctrl + c
import pandas as pd

load Pandas module

pd.DataFrame

creates Pandas DataFrame object

df.type

address type column values

.unique()

will return unique values for a specified column

uniq_vals

will contain resulting array with unique values