Skip to content
Advertisement

How to divide in Panda Python

I generated the following code:

JavaScript

In the second line of the code where I try to divide Second Dose by First Dose, I do not get the right results. Below an example of the output I get:

JavaScript

Instead of getting 527.85 for % Partially Vaccinated I should get 5606041/5870786 = 0.95. Anyone knows what am I doing wrong in the division part of my code ?

Advertisement

Answer

I think the code should be something like this:

JavaScript

For details about the grouping and aggregation in pandas, I recommend to read this official article.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement