I have a dataframe in the below format and and trying to use the extract function but I keep getting the following error:
ValueError: If using all scalar values, you must pass an index
column1 column2
1 abc2150/abc2152/abc2154/abc215601/U215602
df.column2.str
.split('/',expand=True)
.apply(lambda row: row.str.extract('(\d+)', expand=True))
.apply(lambda x: '/'.join(x.dropna().astype(str)), axis=1)
I need the output in the below format.
column1 column2
1 2150/2152/2154/215601/215602
Please let me know how to fix it.
Thanks