So, I have the following Pandas DataFrame where all values in third column (Ratio) are the same:
import pandas as pd
df = pd.DataFrame([[2, 10, 0.5],
[float('NaN'), 10, 0.5],
[float('NaN'), 5, 0.5]], columns=['Col1', 'Col2', 'Ratio'])
╔══════╦══════╦═══════╗
║ Col1 ║ Col2 ║ Ratio ║
╠══════╬══════╬═══════╣
║ 2 ║ 10 ║ 0.5 ║
║ NaN ║ 10 ║ 0.5 ║
║ NaN ║ 5 ║ 0.5 ║
╚══════╩══════╩═══════╝
I want to know if there is a way to multiply Col1 * Ratio and then the output of that product add it to Col2 and append the value to next row Col1 using a function provided by pandas.
Output example:
╔══════╦══════╦═══════╗
║ Col1 ║ Col2 ║ Ratio ║
╠══════╬══════╬═══════╣
║ 2 ║ 10 ║ 0.5 ║
║ 11 ║ 10 ║ 0.5 ║
║ 15.5 ║ 5 ║ 0.5 ║
╚══════╩══════╩═══════╝