ValueError: Incompatible indexer with Series
reason: This problem occurs when a key in the dict refers to more than one value!
e.g.:
df = pd.DataFrame({"A": [1, 2, 3]})
df
# A
#0 1
#1 2
#2 3
num = np.mean(df)
num
#A 2.0
#dtype: float64
Then, when using:
new = pd.DataFrame()
new.at[0, 'A'] = num
ValueError: Incompatible indexer with Series
To modify it:
new.at[0, 'A'] = num.iloc[0]
# A
# 0 2.0
Or:
num = np.mean(df['A'])
new.at[0, 'A'] = num