This is the posdf:
tradingsymbol
0 XYZ2061820500PE
1 XYZ20JUN21000PE
2 ABC20JUN100CE
3 ABC20JUN102.5PE
4 ABC20JUN92.5PE
4 XYZ20JUNFUT
I am doing this to extract the ABC and XYZ to a column:
posdf['symbol'] = posdf['tradingsymbol'].str.extract('^(\D+)', expand=True)
I cannot figure out how I can make a generalised way to extract the following columns:
strike type Expiry
0 20500 PE 20618
1 21000 PE 20JUN
2 100 CE 20JUN
3 102.5 PE 20JUN
4 92.5 PE 20JUN
4 NA FUT 20JUN
Edit
type is min 2 chars max 3.
Expiry is always 5 chars. Which could possibly have this form: 20O18 or 20N18 or 20D18.
2nd Edit
Adding rows where type can be 3 chars based on Sammy's comment.
typeandExpiryalways 2 and 5 chars long?