I feel like I've tried so many iterations of this, can anyone assist with how to use ArcPy to selected layer by attribute then delete selected layer? I think my SQL query is incorrect?
import arcpy
import pandas as pd
import numpy as np
pid_field = ["pid"]
target = arcpy.da.TableToNumPyArray(Master_Subjects, pid_field)
Master_Subjects = r"C:\Users\dsser\Documents\ArcGIS\Projects\MyProject1\Master_Subjects.shp"
target_pid = target[0]["pid"]
# just selecting a random pid here from the Master_Subjects shapefile to see if I can get the select by attribute to work.This is a shapefile feature class with point geometry.
# Also, target_pid is an integer
target_pid = target[0]["pid"]
query = "'" "subject_pid" = target_pid "'"
arcpy.SelectLayerByAttribute_management(Master_Subjects, "NEW_SELECTION", query)
arcpy.DeleteFeatures_management(Master_Subjects)
query = """{0}={1}""".format(arcpy.AddFieldDelimiters(datasource=somelayer, field="subject_pid"),target_pid)print type(target_pid)? SelectLayerByAttribute wants a layer as input, not shapefile. Use MakeFeatureLayer and then Select on this. Your Query has syntax errors, trya = "'" "subject_pid" = target_pid "'"in console and see. Use format like i showed you.