As you mention it might be solved via clustering, but given you need the top n to each other you can go as follows:
Assuming you have matrix X of nxm (n- batteries m- features/attributes of each one)
- Define a distance metric (Euclidean, Mahalanobis, etc)
- Calculate the distance between a battery j and all the other batteries i - j
- Sort the top n distances from a battery
In pseudo code it will be something like this:
def kclosest(frame, battery_id, metric = "euclidean", top = 10):
"""
Return the top n closest from battery id
"""
distances = list()
for index, row in frame.iterrows():
d = metric(frame[frame.id == battery_id].values, row)
distances.append(d)
return sorted(distances)[1:top] # The closest point will always be the itself that's why we get from 1 to top