vendredi 4 septembre 2020

Concatenate on specific condition python

How can i write python code to concatenate the existing string with the day-year of the bill date column into the bill number column (based on an if condition described below)

Functional description:

If bill number ends with '/', concatenate bill_number + bill date (month-year) in the bill_number column Else, leave the bill number as it is.

example of what the existing bill number looks like: CM2/0000/ example of what the bill number should look like (assuming bill_date = 15/09/19) CM2/0000/09-19

dataframe name = df_alldata

I have already tried to use the if df_alldata['bill_number'].endswith('/') but i couldnt come up with the right answer

Aucun commentaire:

Enregistrer un commentaire