close

How to divide two columns element-wise in a pandas dataframe

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to divide two columns element-wise in a pandas dataframe in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to divide two columns element-wise in a pandas dataframe?

  1. How to divide two columns element-wise in a pandas dataframe?

    Just divide the columns:
    In [158]: df['Result'] = df['Column A']/df['Column B'] df

  2. divide two columns element-wise in a pandas dataframe

    Just divide the columns:
    In [158]: df['Result'] = df['Column A']/df['Column B'] df

Method 1

Just divide the columns:

In [158]:
df['Result'] = df['Column A']/df['Column B']
df

Out[158]:
   Column A  Column B  Result
0        12         2     6.0
1        14         7     2.0
2        16         8     2.0
3        20         5     4.0

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read