NLGenin
NLGenin

Reputation: 45

PYTHON - How do I separate a column into two columns based on a delimiter

I need to separate de causaaveria column into two columns. So that I have the description (string) in one column and the number on the other.

idalarmas   fkidparque  tag             naerogenerador  causaaveria                   
4670459     G1037       G1037_001_4_0   A0201           17516 Wtg running limited by P-F tool

Expected result:

idalarmas   fkidparque  tag             naerogenerador  event     causaaveria                     
4670459     G1037       G1037_001_4_0   A0201           17516     Wtg running limited by P-F tool

Thanks!

Upvotes: 1

Views: 36

Answers (1)

Anurag Dabas
Anurag Dabas

Reputation: 24314

Try with split():

df[['event','causaaveria']]=df['causaaveria'].str.split(' ',1,expand=True)

Upvotes: 1

Related Questions