Python Pandas, change table to percentages rather than individual results

3782 views python
0

I am trying to make my table show percentages rather than individual data, but cannot get it to work,

p_table = pd.pivot_table(df, index='party',columns='negotiated',fill_value=0, aggfunc='size')

p_table

This is what I get: Results of table

answered question

1 Answer

12

crosstab

has a normailze option

pd.crosstab(df.party, df.negotiated, normalize=True)

posted this

Have an answer?

JD

Please login first before posting an answer.