How to find all Unique String Items in a Pandas Column

28 January 2018
28 Jan 2018
1 min read

While working on some hockey analysis, I came across an interesting problem: I wanted to find all of the unique values of a certain column. While normally an easy problem by using describe(), this specific column consisted of only string variables; describe() only works for numerical variables.

After researching the problem, I came across the following method:

shot_df.Position.unique()

Where shotdf is my dataframe and Position is the column containing the string values. This will then output any unique values from the position column.

Want to know more?

I spend a ton of time thinking on how to work smarter, not harder. If you'd like to be the first to know what I'm thinking about, sign up to the list below.


NBA Second Screen Opportunity

Introduction to Selenium and PyAutoGui