Hi,
I would like to execute a query in ordert to select all the entries in a certain table by providing a list as input. Basically, I want to obtain nothing different that an inner join between the selected table and the input list itself.
The task would be very easy by using pandas, but putting an entire Rubin table into a dataframe is crazy.
I was trying a work-around with a loop like this, but is extremely slow and unefficient.
Is there a smarter way to do it?
Thanks!
%%time
object_list = []
for candidate in candidate_list:
results = service.search("SELECT id, match_candidate, match_objectId, id_truth_type "\
"FROM dp02_dc2_catalogs.MatchesTruth "\
"WHERE id = "+str(candidate))
results = results.to_table().to_pandas()
# Append objectId to the final list
object_list.append(results['match_objectId'].values)
del results