Reputation: 189
I'm new to Python, lots of JS experience and SQL, and everything I've found so far is counting number of uniques for each value, but all I want is a count of unique values in the column "Team"
uniqueCount= teamTable.groupby('Team').nunique()
print uniqueCount
But this only gives me the error "AttributeError: 'DataFrameGroupBy' object has no attribute 'nunique'"
Thought this would be simple enough to find, but honestly can't find the function
Date ID Team
1/1/2017 A Bears
1/1/2017 A Packers
1/1/2017 A Lions
1/1/2017 B Lions
1/3/2017 A Packers
Upvotes: 2
Views: 2293
Reputation: 294258
Using np.unique
np.unique(df.Team.values).size
3
Followup to @Jeff's comment. He was spot on, @Bernies answer scales the best with my crude test. Might be indistinguishable form @jezrael's over all problem types.
Upvotes: 3