Skip to content
Advertisement

Spitting a column based on a delimiter

I would like to extract some information from a column in my dataframe:

Example

JavaScript

I was using str.contain to extract the first part (i.e., all the information before the first dash, where there is.

JavaScript

I am still getting the same original column (so no extraction). My output would consist in two columns, one without points information (Col1) and another one (Col2) with the text extracted.

JavaScript

and

JavaScript

It is important to consider the first dash where there is, since I might have more dash included in the text. It seems to be this symbol -, but maybe it can be a longer dash. I copied and pasted from my dataset, but copying it here it seems to be slightly different.

Advertisement

Answer

Try using str.extract with Regex.

Ex:

JavaScript

Output:

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