Bottom Page

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,
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python & Dataframe basic question georgialtr 0 469 Apr-06-2020, 03:59 PM
Last Post: georgialtr
  Dataframe replace ilcaa72 0 320 Oct-07-2019, 03:19 PM
Last Post: ilcaa72
  Simple pandas dataframe question popohoma 1 873 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  Newbie question to return only the index of a dataframe zydjohn 0 933 Jan-22-2018, 03:40 PM
Last Post: zydjohn
  very simple dataframe question really_this_dumb 0 832 Jan-02-2018, 11:30 AM
Last Post: really_this_dumb
  Newbie question: how to generate dataframe and use multiple regression zydjohn 0 898 Dec-10-2017, 09:49 AM
Last Post: zydjohn
  pd.DataFrame question smw10c 2 2,112 Mar-30-2017, 09:12 PM
Last Post: smw10c

Forum Jump:


Users browsing this thread: 1 Guest(s)