I have a DataFrame with multiple columns.
base_rate weighting_factor index_1
0 NaN 0
1 1.794836 1
2 1.792804 2
3 1.795893 3
4 1.798023 4
5 1.795517 5
6 1.798652 6
7 1.794425 7
8 1.796899 8
The column
weighting_factor
is empty. Now I want to append values to that column row by row, if the value of
index_1
lies between specific integer boarders.
I tried
if df['index1'] <= oldest_max:
werte_df["weighting_factor"].append(wf_tooold)
whereas wf_tooold is a float and oldest_max is an int.
The error that I get is
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
What would be a good way to fill in the value in the corresponding column?
Code sample to initialize a dataframe:
d = {'index_1': [1,2,3,4,5,6,7,8,9,10,11,12]}
df = pd.DataFrame(data=d)
df["weighting_factor"]= ""