1

I have a dataframe with a column called "Spl" with the values below: I am trying to extract the values next to 'name': strings (some rows have multiple values) but I see the new column generated with the specific location of the memory. I used the below code to extract. Any help how to extract the values after "name:" string is much appreciated.

Column values:

'name': 'Chirotherapie', 'name': 'Innen Medizin'
'name': 'Manuelle Medizin'
'name': 'Akupunktur', 'name': 'Chirotherapie', 'name': 'Innen Medizin'

Code:

df['Spl'] = lambda x: len(x['Spl'].str.split("'name':"))

Output:

<function <lambda> at 0x0000027BF8F68940>

2 Answers 2

1

Just simply do:-

df['Spl']=df['Spl'].str.split("'name':").str.len()
Sign up to request clarification or add additional context in comments.

Comments

1

Just do count

df['Spl'] = df['Spl'].str.count("'name':")+1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.