Stack Overflow Asked by 8-Bit Borges on December 3, 2021
I’m trying to get rid of both inf
and NaN
s in my series.
If I do:
df['Iprod'] = df['PD']/df['PF'].replace(np.inf, 0).fillna(0)
Inf
is gone, but not NaN
.
Is there a one liner to fill NaN
as well?
df.replace([np.nan, np.inf, -np.inf], 0, inplace=True)
Answered by Harshwardhan Nandedkar on December 3, 2021
Adding ()
df['Iprod'] = (df['PD']/df['PF']).replace(np.inf, 0).fillna(0)
Answered by BENY on December 3, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP