'Pandas find matching sub-strings and split on them
I have a pandas column that looks like this:
0 LOT 8 BLK 32 MISSIONARY HEIGHTS
1 LTS 31-39 & PT 30, 15-22 LEWIS
2 LT 2 DEPOT SUB
....
I want to extract out the lot number from this but sometimes they are spelled "LOT", "LTS" or "LT". And I want to extract out the lot number into a new column. So, for the example above, I would have:
df['Lot']
0 8
1 31-39
2 2
How can I do this? Please advise.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|