Input:
import pandas as pd
df=pd.DataFrame({
'Station':['001ABC006','002ABD008','005ABX009','007ABY010','001ABC006','002ABD008'],
'Trains Passing':[55,56,59,96,95,96],
'Destination':['MRK','MRK','MRS','MTS','KPS','KPS']
})
I need to Split the Station text from '001ABC006' to 'ABC' and create a list. Count only the values present in the list. Also group by destination. How could I do it?
Output:
StationId ABC ABD ABX ABY
MRK 1 1 0 0
MRS 0 0 1 0
MTS 0 0 0 1
KPS 1 1 0 0