I am working with airline data. The data looks like the following example:
Itinerary Origin Destination Break
1 A B
1 B C X
1 C B
1 B A X
Where itinerary is the ticket number of a specific person (I used the number 1 here to simplify), and 'break' creates an X after which flight a passenger took a break, meaning it was their final destination.
In this example, I am looking at a round trip connecting flight between cities A and C (where the passenger flew from city A to a layover in city B and eventually to his destination in city C) (I don't care where the layover was), so what I want to get from the above data is the following:
Itinerary Origin Destination
1 A C
1 C A
How can I condense the data to not include the layover locations for each itinerary?
Itinerary Origin Destination Break
1 A B
1 B C X
1 C B
1 B A X
Where itinerary is the ticket number of a specific person (I used the number 1 here to simplify), and 'break' creates an X after which flight a passenger took a break, meaning it was their final destination.
In this example, I am looking at a round trip connecting flight between cities A and C (where the passenger flew from city A to a layover in city B and eventually to his destination in city C) (I don't care where the layover was), so what I want to get from the above data is the following:
Itinerary Origin Destination
1 A C
1 C A
How can I condense the data to not include the layover locations for each itinerary?
Comment