I have a dataframe with person names with these fields - last, first and middle names, i'm trying to concatenating these fields to get a full_name column in a dataframe as below.
dfl.with_columns(
pl.concat_str([pl.col('last_name'),
pl.col('first_name_or_initial'),
pl.col('middle_name_or_initial')],' ').alias('full_name')).select([
pl.col('full_name'),pl.col('last_name'),
pl.col('first_name_or_initial'),
pl.col('middle_name_or_initial')])
Here is the output:
Why I'm getting null in full_name after concatenating last, first and middle_names ? Here If any of field holds null while concatenating strings the result will be NULL like wise in above example last_name is Lee, first_name is James, middle_names is NULL hence full_name is NULL how to ignore NULL field when concatenating the fields.