Get unique values from Pandas series based on string

If I understand correctly, this is a Pandas question.

If so, you can do something like:

unique_vals=df[col].unique()

If col is a string that indicates a column in your DataFrame, and you would like a list of unique values from that column, then this should work.

Also, you can format your code on the forum by wrapping it in backticks with the word Python. This makes it easier for folks to read (and therefore easier to provide assistance). For example,

```python

print('this will be syntax highlighted')

```
3 Likes