Skip to content
Advertisement

Fastest way to filter csv using pandas and create a matrix

input dict

JavaScript

I have large csv files in the below format basename_AM1.csv I have large csv files in the below format

basename_AM1.csv

JavaScript

Now I need to create a similarity dict like below for the given input_dict by searching/filter the csv files

JavaScript

I have come up with the below logic but for an input_dict of 100 samples this takes too long, Can someone please suggest the optimized and fastest way to achieve this

JavaScript

Advertisement

Answer

IIUC, you can use:

JavaScript

If you want 100 on the diagonal:

JavaScript

output:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement