I have this data frame:
df = pd.DataFrame({"A": ["Used", "Not used", "Not used", "Not used", "Used", "Not used", "Used", "Used", "Used", "Not used"], "B": ["Used", "Used", "Used", "Not used", "Not used", "Used", "Not used", "Not used", "Used", "Not used"]})
I would like to find the fastest, cleanest way to find out the following:
- The percentage of rows of all rows that used A.
- The percentage of rows of all rows that used B.
- The percentage of rows of all rows that used A and B.
I am new to Python and pandas (and generally coding), so I'm sure it is very simple, but any recommendations would be appreciated. I tried groupby (). Aggregate (sum), but I did not get the result I needed (I would assume that these are characters, not integers.
source share