Question: Qn(a) : How do modify the code below so so that it is a whole number and shows % sign behind each value. left_percent =
Qn(a): How do modify the code below so so that it is a whole number and shows % sign behind each value.
left_percent = left_pivot.divide(df.pivot_table(index='BusinessUnit', columns='SatisfactionRole', values='LeftCompany', aggfunc='count', fill_value=0)).div(len({'df.index': '%'})).mul(100)
left_percent.fillna(0, inplace=True)
print(left_percent)
Current output:
SatisfactionRole 1 2 3 4 BusinessUnit Business Development 25.974026 25.373134 21.929825 13.445378 HR 45.454545 5.882353 20.000000 7.692308 Product Development 18.238994 12.658228 13.095238 9.486166
Qn (b) : How do I change the bin to ['0%', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%'] with the python code shown below.
import matplotlib.pyplot as plt left_percent.plot(kind='barh', stacked=True, color=['blue', 'orange', 'grey','yellow']) plt.title('Satisfaction with Role'); plt.ylabel("BusinessUnit", rotation=0) plt.show()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
