I have a DataFrame with 3 columns. The 1st column is Temperature. The other two columns of output variables. Sample DataFrame:
import pandas as pd
import numpy as np
data = [(25, 1, 2),
(30, 1, 2),
(25, 1, 2),
(25, 1, 2),
(np.nan, 1, 2),
(40, 1, 2) ]
data_df = pd.DataFrame(data, columns = ['temperature', 'y_1', 'y_2'])
What I want to do is adding a new column to the DataFrame as below:
If value of temperature is 25, use column 'y_1'.
For other cases, use value of column 'y_2'.
For the above example, the new column values will be :
[1, 2, 1, 1, 2, 2]
Thank you for your help.