Python Forum
How to use cse insensitive condition in lambda expresion
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use cse insensitive condition in lambda expresion
#6
(Jul-13-2019, 12:14 PM)SriMekala Wrote: df['value']=df.loc[df['Status'].str.contains('pass', case=False), 'value'] = 0
Doing so you encounter with specificity of chained assignment in Python. This line is equivalent to
temporary = 0
df['value'] = temporary
df.loc[...] = temporary
So, you will get a column of zeros. df.loc[..., 'value'] automatically creates a column if it does not exist, you don't need to create it, e.g. by df['value'] or something else.
Reply


Messages In This Thread
RE: How to use cse insensitive condition in lambda expresion - by scidam - Jul-14-2019, 10:26 AM

Forum Jump:

User Panel Messages

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