Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If Then statement
#11
(Apr-24-2017, 04:39 PM)nilamo Wrote:
(Apr-24-2017, 04:30 PM)smw10c Wrote: Additionally, the code above did not work. It states that "name NaN is not defined".

You should probably share your entire code then, instead of a small snippet which we all knew wouldn't work :P

Haha okay!

dict3={'initial cost': ['$75000.00','$0.00','$30000.00','$1500.00','$19500.00'],'Total Est. Fee':['$986.00','$1144.00','$522.50', '$225.00', '$389.50']}
df3=pd.DataFrame(dict3)
df3['Total Est. Fee']=df3['Total Est. Fee'].str.split('$')
df3['Total Est. Fee']=df3['Total Est. Fee'].str.get(1)
df3['initial cost']=df3['initial cost'].str.split('$')
df3['initial cost']=df3['initial cost'].str.get(1)
df3['Total Est. Fee']=pd.to_numeric(df3['Total Est. Fee'],errors='coerce')
df3['diff']=df3['initial cost']-df3['Total Est. Fee']
df3.diff[df3.diff < 0] = NaN

For some reason the second to last line of code isn't running anymore even though it ran earlier...
Reply


Messages In This Thread
If Then statement - by smw10c - Apr-24-2017, 03:15 PM
RE: If Then statement - by wavic - Apr-24-2017, 03:45 PM
RE: If Then statement - by nilamo - Apr-24-2017, 03:55 PM
RE: If Then statement - by zivoni - Apr-24-2017, 04:15 PM
RE: If Then statement - by nilamo - Apr-24-2017, 04:18 PM
RE: If Then statement - by zivoni - Apr-24-2017, 04:27 PM
RE: If Then statement - by smw10c - Apr-24-2017, 04:30 PM
RE: If Then statement - by nilamo - Apr-24-2017, 04:39 PM
RE: If Then statement - by smw10c - Apr-24-2017, 04:41 PM
RE: If Then statement - by zivoni - Apr-24-2017, 05:08 PM
RE: If Then statement - by smw10c - Apr-24-2017, 05:17 PM
RE: If Then statement - by snippsat - Apr-24-2017, 04:19 PM
RE: If Then statement - by smw10c - Apr-24-2017, 04:25 PM
RE: If Then statement - by zivoni - Apr-24-2017, 04:47 PM
RE: If Then statement - by smw10c - Apr-24-2017, 04:55 PM
RE: If Then statement - by zivoni - Apr-24-2017, 05:35 PM
RE: If Then statement - by smw10c - Apr-24-2017, 07:16 PM
RE: If Then statement - by zivoni - Apr-24-2017, 07:59 PM
RE: If Then statement - by smw10c - Apr-24-2017, 08:10 PM

Forum Jump:

User Panel Messages

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