Skip to content
Advertisement

Tag: string-concatenation

python string concatenation following a sequence

What would be the most pythonic way of creating the following string concatenation: We have an initial dataframe with some of the columns being: origin dest_1_country dest_1_city dest_2_country dest_2_city dest_3_country dest_3_city dest_4_country dest_4_city We want to create an additional column that is the full route for every row in the dataframe and that could be generated by df[‘full_route’] = df[‘origin].fillna(“”)

Pandas string concatenation of row values of a column that have an implicit hierarchy

I have a dataframe signifying the temperature for three days for different regions in India. It’s given in the following image. original_dataframe I need to generate another column in the same dataframe that concatenates the string values of the state and the city which is seen in ‘Col5’ as per the below image. output_dataframe I’m aware of merging the values

Advertisement