Question about the initial analysis

Hi all, I have below questions. Please help!!

1,We tried to calculate the percentage of the employee who resigned due to dissatisfaction. In the dissatisfied columns, we only have True and False. True means that employee resigned due to dissatisfaction. When python calculated the percentage by df.pivot_table, how does it know calculate only True value? I also use df.groupby,agg() to get the same output as I used df.pilvot_table().I just tried agg(mean), it works. but i dont know why i can use mean to calculate the columns which datatype is string.

2, How to move the legend to the upper center?

Thank you so much in advance !!

Screen Link:

My Code:



# Plot the results
%matplotlib inline
resignation_per.plot(kind='bar',legend=True, rot=30)

What I expected to happen:
I expected the output with 2 percentage number, one is calculated for True, another one is calculated for False.

What actually happened:

Established      0.774194
Experienced      0.581395
New              0.476684
Veteran          0.808824

Hi @candiceliu93

  1. Python makes the calculation same way as us. I mean it counts how many trues and falses are and divide them by the total amount of rows.

  2. To change the location of the legend box you can use plt.legend(loc=9), or you can use loc=‘0’ to find the best location. The documentation can help you with that