Skip to content

Tag: division

How to divide in Panda Python

I generated the following code: 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: Instead of getting 527.85 for % Partially Vaccinated I should get 5606041/5870786 = 0.95. Anyone knows what am I doing wrong in …

Make division by zero equal to zero

How can I ignore ZeroDivisionError and make n / 0 == 0? Answer Check if the denominator is zero before dividing. This avoids the overhead of catching the exception, which may be more efficient if you expect to be dividing by zero a lot.