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
85 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
646 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
31 views
0 votes
2 answers
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
62 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
99 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
702 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
1,293 views
+1 vote
2 answers

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

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE) ...READ MORE

answered Aug 14 in Data Analytics by anonymous
74 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,520 points
3,490 views