Keep in mind the 'None' value is a string so can't use .fillna
df[df['TRIPLINE'] == 'None']
I want to fill these string values with the corresponding value in the 'LINE' column
Keep in mind the 'None' value is a string so can't use .fillna
df[df['TRIPLINE'] == 'None']
I want to fill these string values with the corresponding value in the 'LINE' column
As long as None is truly a string and not a np.nan or None you can use np.where()
import numpy as np
df['TRIPLINE'] = np.where(df['TRIPLINE'] == 'None', df['LINE'], df['TRIPLINE'])
Use .loc
with your == 'None'
mask:
act_thruput_raw.loc[act_thruput_raw['TRIPLINE'] == 'None', 'TRIPLINE'] = act_thruput_raw['LINE']
IIUC,
df['TRIPLINE'] = df['TRIPLINE'].mask(df['TRIPLINE'] == 'None', df['LINE'])