Anant Sakhare
Anant Sakhare

Reputation: 13

How I write a python code for multiply each element in row?

Here is a data frame I wanted same output.
Please tell me how should I write a python code to solve question...

DF

    A    B    C
1   1    2    3
2   1    3    5
3   1    1    1  

And I need A output like

Answer:

      Multiplication
1         6
2        15
3        1

Upvotes: 0

Views: 68

Answers (1)

Erfan
Erfan

Reputation: 42886

Use DataFrame.prod over axis=1

df.prod(axis=1)

1     6
2    15
3     1
dtype: int64

Upvotes: 3

Related Questions