I have a dataframe:
import pandas as pd
import numpy as np
df = pd.DataFrame(
data={'X': [1.5, 6.777, 2.444, np.NaN],
'Y': [1.111, np.NaN, 8.77, np.NaN],
'Z': [5.0, 2.333, 10, 6.6666]})
I think this should work, but i get the following error;
df.at[1,'Z'] =(df.loc[[2],'X'] df.loc[[0],'Y'])
How can I achieve this?
ValueError: setting an array element with a sequence.
CodePudding user response:
This should work
df.loc[1, 'Z'] = df.loc[2,'X'] df.loc[0,'Y']