I got a dataframe that contains columns with numbers where some are a single number (1234) and others contains multiple numbers(12340-567-8900) I found a way to split the multiple numbers, but if my columns contains single numbers my code fails.
Can anyone point me in the right direction?
`lens = df['EPDNr'].str.split('-').map(len)
res = pd.DataFrame({'Title':np.repeat(df['Title'],lens),
'Kundenummer':np.repeat(df['Kundenummer'],lens),
'Avvikstype':np.repeat(df['Avvikstype'],lens),
'Ordrenummer':np.repeat(df['Ordrenummer'],lens),
'EPDNr':chainer(df['EPDNr']),
'Antall':chainer(df['Antall'])})
I want my output to look like Column header: EPDNR Cell a1 1234 Cell a2 12340 Cell a3 567 cell a4 8900 ect..
pd.Series(['1234-567-8900','1234']).str.split('-').str[0]