Well, there are a couple of things going on. First,
dataset[All, "y"] // Normal
returns a new expression:
{163, 183, 104, 191, 161}
So, that is what ReplacePart
will work on. You won't be updating dataset
at all. So, if you were expecting to update dataset
, the explanation can stop there. If you want to know why that new expression wasn't modified, it's because your position specification didn't correspond to an existing place in this new structure.
ReplacePart[dataset[All, "y"] // Normal, {2, 5} -> Null]
will look for position {2,5}
(which corresponds to something like x[[2,5]]
). The main argument is just a flat list, however, so there is no "fifth element in the second element" to be replaced. Presumably, what you wanted to replace was two things, the second and the fifth element. To do that, you need a list of positions: {{2},{5}}
. Like this:
ReplacePart[dataset[All, "y"] // Normal, {{2}, {5}} -> Null]
(* {163, Null, 104, 191, Null} *)