How to delete values based on non-existence of a tag

I also have this question! Perhaps an example will help. I have data with two tags, “sensor” and “units”. I want to delete any points without a “units” tag.

I can find this data to delete via filter():

from(bucket: "iotawatt")
  |> range(start: start, stop:  stop)
  |> filter(fn: (r) => not exists r.units

This returns:

_value      _time                       sensor
3761.39		2023-07-21T04:50:00.000Z	Production
4902.29		2023-07-21T04:51:00.000Z	Production

I can delete all points for sensor==“Production” data like so:

influx delete -p 'sensor=="Production"' --bucket "iotawatt" --start 2020-06-27T00:00:00+10:00 --stop 2023-09-01T00:00:00+10:00 --org myorg 

But I only want to delete data without a Units tag.

How can I do that?

Thanks!

ps. I’m actually using the python client, but it’s just an interface to the same API and as the CLI.
pps. The related problem I’m trying to resolve via this delete is duplicate(?) points.