Skip to content
Advertisement

How to extract a string from one column and save it in a new column in pandas dataframe?

This is my dataframe:

JavaScript

I want to extract from refactorings column : Add parameter which is the type and com.github.pockethub.android.core.issue.IssueFilter which is after from class and put them into a new column and then delete refactorings column.

The Wanted datframe is:

JavaScript

this is my code:

JavaScript

It did not extract correctly the refac and class: For the refac it return 'Add and for the class it return com.github.pockethub.android.core.issue.IssueFilter', also it did not create any new column and it did not delete refactorings column!

Advertisement

Answer

use regexp with str.extract()

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