Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How in Pandas Dataframe and Python can extract the specific text string after a given word?

I would like to extract the text inside the range "text: ….." from this dataframe and create another column with that value.

This is my Pandas Dataframe

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

issues_df['new_column'] = issues_df['fields.description.content'].apply(lambda x: x['text'])

However, it returns the following error:

issues_df['new_column'] = issues_df['fields.description.content'].apply(lambda x: x['text'])
TypeError: Object 'float' is not writable.

Any suggestions?

Thanks in advance.

>Solution :

Problem is NaN in column, you can try .str accessor

issues_df['new_column'] = issues_df['fields.description.content'].str[0].str['content'].str[0].str['text']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading