I have the following dataset:
dataset=Dataset[{
<|"x" -> -1, "y" -> 163|>,
<|"x" -> 4, "y" -> 183|>,
<|"x" -> -7, "y" -> 104|>,
<|"x" -> -5, "y" -> 191|>,
<|"x" -> 2, "y" -> 161|>
}]
I want to replace every "y" element for which the corresponding "x" values is larger than 0, into Null, and thus to get the new dataset
Dataset[{
<|"x" -> -1, "y" -> 163|>,
<|"x" -> 4, "y" -> Null|>,
<|"x" -> -7, "y" -> 104|>,
<|"x" -> -5, "y" -> 191|>,
<|"x" -> 2, "y" -> Null|>
}]
I have a few loose ends to tie up:
dataset[Select[#x > 0 &]]givse the rows with"x"value > 0dataset[Select[#x > 0 &], "y"]gives the corresponding"y"valuesPosition[dataset[All, "x"] // Normal, _?(# > 0 &)]gives the row numbers for which"x"> 0RepacePartcan be used to modify the values; I don’t know why butReplacePart[dataset[All, "y"] // Normal, {2, 5} -> Null]doesn’t work
So I need some help with getting it to work.
Any help would be very welcome!