rps = {'Played' : ['Rock', 'Scissors', 'Scissors', 'Rock', 'Scissors', 'Paper', 'Scissors', 'Paper', 'Scissors', 'Paper', 'Rock', 'Paper', 'Scissors', 'Paper', 'Paper', 'Rock', 'Paper', 'Rock', 'Paper', 'Rock', 'Rock', 'Scissors', 'Paper', 'Rock', 'Rock', 'Scissors', 'Paper', 'Rock', 'Rock', 'Scissors', 'Paper', 'Rock', 'Scissors', 'Paper'], 'Outcome' : ['Won', 'Lost', 'Lost', 'Won', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Lost', 'Won', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost', 'Won', 'Lost']} import pandas as pd rps = pd.DataFrame(rps) ## View the data first print(rps) ## Find two-way table ## Find the proportion that played Rock and Won ## View the data first print(rps) ## Find two-way table twt = pd.crosstab(rps['Played'], rps['Outcome'], margins=True) twt ## Find the proportion that played Rock and Won print('Proportion = ', twt.loc['Rock', 'Won']/twt.loc['Rock', 'All'])