Last Updated: 2022-05-26
This tip is a simple intuition (that seems near obvious in retrospect) about guessing the argument form in some dependency's API.
I struggled using the Python pandas'
.iloc method. My goal was to get the data
for a certain column (
real_prob was its title) available on a bunch of rows
with known index locations.
My code was:
row_indexes = [899, 1044, 482...] df.iloc[row_indexes, "real_prob"] = 0.9
This failed. The errors didn't help me solve it, but I eventually realized that
iloc expected numerical indexes for every dimension. Therefore this would
have worked (assuming
real_prob was the 4th column - 3rd with 0-indexing)
row_indexes = [899, 1044, 482...] df.iloc[row_indexes, 3] = 0.9
Or I could have calculated it dynamically:
df.iloc[row_indexes, df.columns.get_loc("real_prob")] = 0.9