Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Given 3 series merge to create a new series with 1 column containing numbers of each dataframe

I have 3 series with data like below

s1 = [1,1,3]
s2 = [2,3,2]
s3 = [4,2,1]

I want to create a new series with values such that

s_new = [124,132,321]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

please note that s_new = int(''.join(s1,s2,s3))
I know the above syntax is wrong but you get the idea.

>Solution :

You can do with pandas agg

s = pd.DataFrame([s1,s2,s3]).astype(str).agg(''.join).astype(int).tolist()
Out[334]: [124, 132, 321]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading