I have this operation:
df['netPCR'] = df['ValorNeto'] / df.index.map(PCR['ValorNeto'])
df['netPCR'] = df['netPCR'].fillna(0)
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.
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.
CodePudding user response:
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)