I am working on a Pandas issue.
Currently in df1:
| start | Stop |
|---|---|
| NYPenn | WUnion |
| GCTerm | 30thSt |
| TUStat | LAUnio |
| JaStat | MillSt |
| ChiUnS | MonCen |
| OGTran | SouthS |
Currently in df2 (Prime):
| Train_Code | City |
|---|---|
| NYPenn | New York City |
| WUnion | D.C. |
| GCTerm | New York City |
| 30thSt | Philadelphia |
| TUStat | Toronto |
| LAUnio | Los Angeles |
| MonCen | Montreal |
| OGTran | Chicago |
| SouthS | Boston |
I want to use the train codes to determine which start/stop in df1 contain prime stations. I would need to run each element in both columns in df1 against df2 (Train_Code) to output the results indicating which station was a prime (or if both stations are prime) into another dataframe (df3).
df3 should end up being:
| start | Stop | Results | City | Results | City |
|---|---|---|---|---|---|
| NYPenn | WUnion | Yes | New York City | Yes | D.C. |
| GCTerm | 30thSt | ||||
| TUStat | LAUnio | ||||
| JaStat | MillSt | NO | NaN | NO | NaN |
| ChiUnS | MonCen | NO | NaN | Yes | Montreal |
| OGTran | SouthS |
**Note: I didn't fill in df3 all the way but I gave examples of how it should be filled.
[If I added another column indicating there was a layover station, the code should work run against the layover column as well.]