user11645903
user11645903

Reputation:

Stack Data Frames on top of one another dataframe

I have two dataframes :

1st dataframe

Countrey    2000    2001    2002    2003    2004    2005

canada      779      771     754     740     760     747
mexico      1311.2  1285.2  1271.2  1276.5  1270.6  1281
usa         836     814     810     800     802     799
India       914     892     888     878     880     877
China       992     970     966    956       958    955

2nd dataframe

year        2000    2001    2002    2003    2004    2005
data        1.1     1.2     1.3    1.4       1.5    1.6

i would like to merge above these two dataframe in following way?is it possible?

data        1.1      1.2    1.3     1.4      1.5    1.6
Countrey    2000    2001    2002    2003    2004    2005
canada      779     771      754    740      760    747
mexico      1311.2  1285.2  1271.2  1276.5  1270.6  1281
usa         836      814    810     800      802    799
India       914      892    888     878      880    877
China       992      970    966     956      958    955
Sum        4832.2   4732.2  4689.2  4650.5  4670.6  4659

also i wants the sum of each column

Upvotes: 0

Views: 1000

Answers (1)

Anshul Verma
Anshul Verma

Reputation: 377

You could use pandas.concat() or DataFrame.append() , check pandas document its easily available with examples.

Upvotes: 0

Related Questions