Answers for "python - concatenate if null"

0

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'
Posted by: Guest on July-02-2020

Python Answers by Framework

Browse Popular Code Answers by Language