I am trying to change one column value based on other columns value. Can you please help me how to do this?
Example:
priority comb_fld_order start_bracs end_bracs
1 (
1.1
2.3 1 (
2.3.1 1 )
3.7 )
Expected Output:
priority comb_fld_order start_bracs end_bracs
1
1.1
2.3 1 (
2.3.1 1 )
3.7
Means if comb_fld_order is null then we should to remove brackets from start_bracs and end_bracs column.
You can create a boolean mask using Series.eq
, then use Series.where
to replace the values based on condition:
m = df['comb_fld_order'].eq('')
df['start_bracs'] = df['start_bracs'].where(~m, '')
df['end_bracs'] = df['end_bracs'].where(~m, '')
Result:
# print(df)
priority comb_fld_order start_bracs end_bracs
0 1
1 1.1
2 2.3 1 (
3 2.3.1 1 )
4 3.7
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments