Python Forum
Question for dataframe to replace INF value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question for dataframe to replace INF value
#1
import pandas as pd
df1 = pd.DataFrame({'a': [1.0, 1.1, 1.2 ], 'b': [ 0.5, 1.1, 1.0 ]})
mid = (df1['a'] + df1['b']) / 2.0
aMid = df1['a'].sub(mid)
bMid = df1['b'].sub(mid)
aWid = (a1 / aMid)
bWid = (a1 / bMid)
print(aWid)
print(bWid)
I want to replace the INF result in aWid or bWid, where the result is divided by 0, and replace the INF result by 0.0
Please help.
Thanks,
Reply


Messages In This Thread
Question for dataframe to replace INF value - by zydjohn - Jan-15-2018, 10:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PANDAS: DataFrame | Replace and others questions moduki1 2 1,758 Jan-10-2022, 07:19 PM
Last Post: moduki1
  Python & Dataframe basic question georgialtr 0 3,833 Apr-06-2020, 03:59 PM
Last Post: georgialtr
  Dataframe replace ilcaa72 0 1,494 Oct-07-2019, 03:19 PM
Last Post: ilcaa72
  Simple pandas dataframe question popohoma 1 3,493 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  Newbie question to return only the index of a dataframe zydjohn 0 2,521 Jan-22-2018, 03:40 PM
Last Post: zydjohn
  very simple dataframe question really_this_dumb 0 2,156 Jan-02-2018, 11:30 AM
Last Post: really_this_dumb
  Newbie question: how to generate dataframe and use multiple regression zydjohn 0 2,252 Dec-10-2017, 09:49 AM
Last Post: zydjohn
  pd.DataFrame question smw10c 2 3,967 Mar-30-2017, 09:12 PM
Last Post: smw10c

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020