Home > OS >  Extract text from a series into new columns
Extract text from a series into new columns

Time:02-11

I've tries the following code with the following error message:

AttributeError: 'DataFrame' object has no attribute 'str'

I'm referencing a string series, then why am i getting a "Dataframe" error?

df['PO'] =  df['extract'].str.extract(r"(?:^(?=[A-Z\d/-] $)|\bPO\W*)([A-Z\d/-] )")

CodePudding user response:

Problem is with duplicated columns names, so if select one column extract get all columns in DataFrame.

print (df['extract'])

For deduplicted is simpliest set columns names or some another solution:

df.columns= ['a','b']
  • Related