pandas merge 递归

递归

    def df_merge(self, df_lst):
        df_len = len(df_lst)
        if df_len == 1:
            return df_lst[0]
        elif df_len == 2:
            return df_lst[0].merge(df_lst[1], on=["company", "site_id", "site_name"], how="right")
        else:
            return self.df_merge(df_lst[0:df_len-1]).merge(df_lst[df_len-1], on=["company", "site_id", "site_name"], how="right")

 

posted @ 2020-05-11 13:40  市丸银  阅读(326)  评论(0编辑  收藏  举报