Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I have inf values in a dataset column that don't see like inf at all

I have this operation:

df['netPCR'] = df['ValorNeto'] / df.index.map(PCR['ValorNeto'])

df['netPCR'] = df['netPCR'].fillna(0)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But some how when

df['netPCR'].sum()

It results in inf and when I try to get what values are inf things just get weird.

enter image description here

What do you think it is happening and how to fix it?

I tried to round values or convert them to objects, but the problem is not fixed.

>Solution :

It seems like division by 0 is returning infinity and not nan. You can use df.replace:

df.replace([np.inf, -np.inf], 0, inplace=True)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading