The pandas.DataFrame doesn’t seem to accept tensors as indices.
I guess the tolist() operation might not really be necessary, but instead a Python literal might work.
You could check it by using idx = idx.item() and rerun the script.