Skip to content
Advertisement

How to remove text and remain with interger values in python dataframe column

I have a dataframe with the column as follows;

JavaScript

I want the output as follows:

JavaScript

I have tried,

JavaScript

No success so far.

Advertisement

Answer

This depends on what possible values can be in the quantity column. If there can never be a space in the numerical part (as in your example) you can use Series.str.partition:

JavaScript

This can also be written in one line:

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