I have a Dataframe with two columns "Start_location" and "end_location". I want to create a new column called "location" from the 2 previous columns with the following conditions.
If the values of "start_location" == "end_location", then the value of "location" will be either of the values of the first two columns.
else, if the values of of "start_location" and "end_location are different, then values of "Location" will be "start_location"-"end_location".
An example of what I want is this.
+---+--------------------+-----------------------+
| | Start_location | End_location |
+---+--------------------+-----------------------+
| 1 | Stratford | Stratford |
| 2 | Bromley | Stratford |
| 3 | Brighton | Manchester |
| 4 | Delaware | Delaware |
+---+--------------------+-----------------------+
The result I want is this.
+---+--------------------+-----------------------+--------------------+
| | Start_location | End_location | Location |
+---+--------------------+-----------------------+--------------------+
| 1 | Stratford | Stratford | Stratford |
| 2 | Bromley | Stratford | Brombley-Stratford |
| 3 | Brighton | Manchester | Brighton-Manchester|
| 4 | Delaware | Delaware | Delaware |
+---+--------------------+-----------------------+--------------------+
I would be happy if anyone can help.
PS- forgive me if this is a very basic question. I have gone through some similar questions on this topic but couldn't get a headway.