Adding values of common columns in pandas dataframe

0 votes

Let's say i have two pandas dataframes like this:

Set1: 

   x   y
0  10  20
1  30  40
2  50  60

Set2:

   x   y
0  60  50
1  40  30
2  20  10

Now, these two dataframes have the same column names and same index numbers. I would want to add the corresponding values of each column, so the resultant should look like this:

   x   y
0  70  70
1  70  70
2  70  70
May 30, 2018 in Data Analytics by zombie
• 3,690 points
65 views

1 answer to this question.

0 votes
Result = Set1.add(Set2)
   x   y
0  70  70
1  70  70
2  70  70

answered May 30, 2018 by Bharani
• 4,550 points

Related Questions In Data Analytics

0 votes
1 answer

How to drop rows of Pandas DataFrame whose value in certain coulmns is NaN

Easy Way: This Way we can easily handle ...READ MORE

answered May 7, 2018 in Data Analytics by DeepCoder786
• 1,700 points
602 views
0 votes
1 answer

How can I find number of columns in a dataframe

To know the number of columns in ...READ MORE

answered Oct 11, 2018 in Data Analytics by ANMOL
• 3,620 points
25 views
0 votes
1 answer
0 votes
3 answers

Code snippet to find number of null values in each column in a dataframe in R

colSums(is.na(data_frame_name)) will return you number of nulls ...READ MORE

answered Jul 5 in Data Analytics by sindhu
19 views
0 votes
1 answer

How to rename columns in pandas (Python)?

It is easy by just adding ".columns" ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,700 points
73 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,700 points
642 views
0 votes
2 answers
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,550 points
973 views
+1 vote
1 answer

Custom Function to replace missing values in a vector with the mean of values

You have missed out on "na.rm=TRUE" inside ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,550 points
47 views
+1 vote
3 answers

Problem with installation of Wordcloud in anaconda

Using Anaconda Python 3.6 version For Windows ...READ MORE

answered Aug 7, 2018 in Data Analytics by Priyaj
• 56,160 points
2,618 views