Dfs Algorithm In Python Using Pandas And Numpy