Consider the following pandas dataframe:
df = pd.DataFrame({'a': [1, 2, None, 3, None]}, index=[0, 1, 2, 3, 4])
I want to replace to the nan values with some other values from the same data frame, for example:
df.loc[[2, 4]] = df.loc[[0, 1]]
But that does not work. The result is the exact same data frame as before the assignment. What I can do, however, is
df.loc[[2, 4]] = 999
and
df.loc[[2, 4]] = [999, 777]
and consequently also
df.loc[[2, 4]] = df.loc[[0, 1]].to_numpy().tolist()
All these examples replace the indexed values with the values given on the rhs, as expected.
Question is, why does the first assignment not work in the same manner? If that's a noop, I think, there should at least be warning.