Skip to content
Advertisement

Error re.findall() when used in a iteration over a list from pandas dataframe

I converted a column to list from a pandas df:

JavaScript

I wanted to separate this kind of strings: ‘BuyMeADrink’ into ‘Buy Me A Drink’

So I used one of the following:

JavaScript

or

JavaScript

or

JavaScript

All of the above returned this:

TypeError: expected string or bytes-like object

I understand that findall() needs strings not list, but here I am iterating over a list that returns strings, why I get this error then?

Thank you.

Advertisement

Answer

Let’s try replace:

JavaScript

Output:

JavaScript

However, your problem is inherently ambiguous, e.g. how should you split 'ElectionInTheUSA'

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement