I have a dataframe, and I want to iterate change the values of some rows depending on some calculations I'm doing in a loop.
So for example: if a condition is met, Then I want to change the centers, that are the values in a row of my dataframe.
This are my centers:
centers=[np.array([ 4.73478261, 3.10869565, 1.44782609, 0.20434783]),
np.array([ 5. , 2.4 , 3.2 , 1.03333333]),
np.array([ 5.135, 3.555, 1.48 , 0.275]),
np.array([ 5.52857143, 4.04285714, 1.47142857, 0.28571429]),
np.array([ 5.596, 2.664, 4.052, 1.252]),
np.array([ 6.01176471, 2.71176471, 4.94705882, 1.79411765]),
np.array([ 6.4 , 2.97058824, 4.55294118, 1.41176471]),
np.array([ 6.49090909, 2.9 , 5.37272727, 1.8 ]),
np.array([ 6.61333333, 3.16 , 5.56666667, 2.28666667]),
np.array([ 7.475, 3.125, 6.3 , 2.05 ])]
I then convert them to a dataframe
centersDf = pd.DataFrame(centers)
centersDf
and I would like to do something like,
centersDf[i]=np.array[5, 1, 0 , 2 ]
This doesn't work, but what could be the equivalent? So, I'm recalculating the centers in my loop, and I want to update my dataframe.
centersDf.iloc[i]instead ofcentersDf[i]. The latter refers to the i'th column.