I have a pandas DataFrame like this; it shows a history of stock investing. In the Profit column, 1 means profitable and 0 means loss-making.
Stock Year Profit Count
AAPL 2012 0 23
AAPL 2012 1 19
AAPL 2013 0 20
AAPL 2013 1 10
GOOG 2012 0 26
GOOG 2012 1 20
GOOG 2013 0 23
GOOG 2013 1 11
I have to find out the percentage of profitable investments:
Stock Year Profit CountPercent
AAPL 2012 1 38.77
AAPL 2013 1 33.33
GOOG 2012 1 43.47
GOOG 2013 1 32.35
I tried using the method in this post
but it shows 'TypeError: Join on level between two MultiIndex objects is ambiguous'
.