How to strip column and combine?

df: 
   home_score  away_score
1         0.0         1.0
2         2.0         1.0
3         3.0         2.0
4         0.0         0.0
5         1.0         1.0

Expected result:

    score
--  -------
 0  0:1
 1  2:1
 2  2:1
 3  3:2

I am trying

df['home_score'] = df['home_score'].astype(str).str.replace('^.*(.\d)', '', regex=True)

to strip the score before combining columns but I am not getting anything..

Also, this code worked on regex101 How do I figure out this to work in python?



from Recent Questions - Stack Overflow https://ift.tt/3E89II4
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)