Skip to content
Advertisement

Delete specific strings from pandas dataframe with operators chaining

I want to delete specific strings with regular expressions from the column Sorte which I don’t want to have in my dataframe file_df with the following code:

JavaScript

But somehow when I execute this code these strings still are in the dataset and I can not figure out why. I wanted to chain this expression to not create so many copies.

Update

The code worked for some strings in the dataset, for others not.

Advertisement

Answer

I figured out another solution that worked out for me derived from the answer at https://stackoverflow.com/a/54410702/14553595, which is basically a combination of your suggestions in the comments:

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