1

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/-]+)")
DarrylG
  • 16,732
  • 2
  • 17
  • 23
amit singh
  • 197
  • 6

1 Answers1

0

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']
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252