The dataframe has 3K and with two for loops the complexity becomes 3k**2 taking too long to run , I need way to sove this problem,below is my program.