How to get unique values in a column in pandas

Spread the love

Problem –

You have a column in a DataFrame and you want to get all the unique values from that column.

Solution –

import pandas as pd

url = ""
df = pd.read_csv(url)

Let’s say that you want all the unique values in the Method of Payment column.

df['Method of Payment'].unique()

You can also apply it to a numerical column.


Rating: 1 out of 5.

Leave a Reply