I want to create a count of unique values from one of my Pandas dataframe columns and then add a new column with those counts to my original data frame. I've tried a couple different things. I created a pandas series and then calculated counts with the value_counts method. I tried to merge these values back to my original dataframe, but I the keys that I want to merge on are in the Index(ix/loc).
Color Value
Red 100
Red 150
Blue 50
I want to return something like:
Color Value Counts
Red 100 2
Red 150 2
Blue 50 1
See Question&Answers more detail:os