
Instead, the NaN value is added to the column. The output dataframe will show that the rows with the Null or missing values are not combined. df = df.map(str, na_action=None) + df.map(str, na_action='ignore')
#Combine two dataframes pandas how to#
The following code demonstrates how to ignore missing values during concatenation. The na_action = None parameter in the map() method denotes that the Null or missing values must be ignored during concatenation. Now, use the map() method and (+) operator to combine two string columns of the dataframe. df = df.map(str, na_action=None) + df.map(str, na_action='ignore')Īdd another row to the dataframe with None values to learn how the map() method handles these values during concatenation.Ĭode df.loc = The following code uses the map() method to handle the Null values and uses the Plus (+) operator to concatenate the values.

You’ll use the columns in the dataframe df to learn different concatenation methods. Use these columns to concatenate and create a new column. Concatenate Two Columns With a Separatorįor the demonstration, you’ll use the below dataframe.Convert to Text and Combine Two Columns.
