Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Multiply two columns of different dataframes in Python

$
0
0

I have two dataframes (both are datatype float). The first one is called Prices which contains only prices:

df Prices

The second one is called Table_ScenarioPercentages which contains percentages where the prices need to be multiplied by:

df Table_ScenarioPercentages

So what I want to do is multiply the value of Period 20240201 (Prices) by Month 0 (Table_ScenarioPercentages), the value of Period 20240301 (Prices) by Month 1 (Table_ScenarioPercentages), etc.

I've tried:

Prices.iloc[:, 0]*Table_ScenarioPercentages.iloc[:, 0] 

but this just gives a lot of NaN's and the wrong format:

result multiplication

Does someone know how to do this in Python?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>