Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python - concatenate if null

# Option 1
df['concat'] = np.where(df['var_1'] == '', df['var_2'], df['var_1'] + '_u')

# Option 2
def concat_fields(field1, field2):
        if field1.empty:
            return field2
        else:
            return field1 + '_u'  
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #concatenate #null
ADD COMMENT
Topic
Name
5+4 =