i need write predicate function determine if 2 indexes have same tuples. has been solved million times.
given following 2 measure tables
wave respondent source 0 1 1 1 1 1 2 1 2 3 1 2 4 1 1 0 2 2 1 2 2 2 2 1 3 2 1 4 2 2 score respondent source 0 1 1 1 1 1 2 1 2 3 1 2 4 1 1 same_indexes(df_a, df_b)
the output
[true, true, true, true, true, false, false, false, false, false]
it should ideally handle indexes in different orders , need handle variable numbers of indexes.
a pandas index
(or multiindex
, in question) implements isin
method you're looking for. use df_a.index.isin(df_b.index)
.
Comments
Post a Comment