I'm reading in a csv and I'm trying to count how many times each entry appears The csv looks like this:
Image# color1 color2 color3
1 red blue yellow
2 blue blue red
3 white red pink
What I'm wanting to do is write it to a new csv with something like:
df = pd.read_csv("colors.csv")
counted = df.groupby(["color1", "color2", "color3"]).size()
df.to_csv("counted.csv")
except I want it to output
Red 3
Blue 3
Pink 1
Yellow 1
White 1
I'm fine if there isn't a way to do this, but how would I at least get the total occurrences of each of those colors? Thanks