Select to view content in your preferred language

Python notebook to delete features in hosted table when any set of 3 values in 3 distinct fields repeats

851
4
Jump to solution
11-09-2023 12:00 PM
DavidFrisbey
Emerging Contributor

Hi super smart Esri Community,

I am seeking a solution to delete rows in a hosted table through python script in a notebook on AGOL. I can't use any solution that touches a local file like a csv file.  

The chunk before this need is:

# delete features with where avg_ is less than 2
Carc.delete_features(where="avg_ < 2")

# where Carc = DavidFrisbey_0-1699558902706.png

The need is something that will delete all rows from this table if three distinct fields within Carc repeat.

For example, in the picture below, the solution would leave each row in the table with a unique set of 3 values in the fields sensor_id,  time_stamp, and avg_. So, in the picture below, the solution would leave the 2 first rows and remove 2 of 4 of the last 4 rows, because they have non-unique sets of sensor_id,  time_stamp, and avg_.

DavidFrisbey_1-1699559275965.png

Best, 

Eli L

0 Kudos
1 Solution

Accepted Solutions
KellyTaylor
Regular Contributor

I haven't tested this so you may have to mess with it a bit but I believe the logic is solid

KellyTaylor_0-1700082459154.png

View solution in original post

0 Kudos
4 Replies
AlfredBaldenweck
MVP Regular Contributor
0 Kudos
DavidFrisbey
Emerging Contributor

Thank you, Alfred. I don't normally use the advanced runtime required for arcpy, yet it is a simple, good solution and I appreciate your time and help.

0 Kudos
KellyTaylor
Regular Contributor

I haven't tested this so you may have to mess with it a bit but I believe the logic is solid

KellyTaylor_0-1700082459154.png

0 Kudos
DavidFrisbey
Emerging Contributor

Thank you, Kelly. That works great!

0 Kudos