I have a probleme where I have a pandas DataFrame with name df_x where my index is the name of persons and my columns are the name of products. The values are the distance between these persons to the products I want to build another table containing the columns of df_x and as values the name of the person that have the minimun distance to this product.

Is there a simple way to do this using pandas or np? Do I need to use for loop?


(index)  Banana  Apple
Mike     7       2
Kevin    2       4
James    3       6

皇冠hg0088代理网址so the final table should be

(index)  Banana  Apple
Name     Kevin   Mike




     Banana  Apple
Name   Mike  James
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.