Skip to content
Advertisement

split the string in dataframe in python

I have a data-frame and one of its columns are a string which separated with dash. I want to get the part before the dash. Could you help me with that?

JavaScript

The desire output is: enter image description here

Advertisement

Answer

You could use str.replace to remove the - and all characters after it:

JavaScript

Output:

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