This line returns the first 4 rows in the dataframe combined
for feature_a
combined.iloc[0:4]["feature_a"]
As expected, this next line returns the 2nd, 4th, and 16th rows in the dataframe for column feature_a
:
combined.iloc[[1,3,15]]["feature_a"]
This line sets the first 4 rows in the dataframe for feature_a
to 77
.
combined.iloc[0:4]["feature_a"] = 77
This line does something. Some sort of computations are happening since it takes longer when applied to a longer list.
combined.iloc[[1,3,15]]["feature_a"] = 88
The 2nd, 4th, and 16th rows are not set to 88
when checked with this:
combined.iloc[[1,3,15]]["feature_a"]
How can I set an arbitrary list of rows of a column of a dataframe to a value without taking a massive coding detour?
This scenario seems like it should be pretty straightforward and common.