list_builder.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:seniority_list 作者: rubydatasystems 项目源码 文件源码
def test_df_col_or_idx_equivalence(df1,
                                   df2,
                                   col=None):
    '''check whether two dataframes contain the same elements (but not
    necessarily in the same order) in either the indexes or a selected column

    inputs
        df1, df2
            the dataframes to check
        col
            if not None, test this dataframe column for equivalency, otherwise
            test the dataframe indexes

    Returns True or False
    '''
    if not col:
        result = all(np.in1d(df1.index, df2.index,
                             assume_unique=True,
                             invert=False))
    else:
        result = all(np.in1d(df1[col], df2[col],
                             assume_unique=False,
                             invert=False))

    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号