Skip to content
Advertisement

find out if the indexes of a grouped data frame match a column of another dataframe?

I have a grouped data frame named df_grouped where AF & Local are the indexes. I would like to assert whether the indexes in df_grouped are equal to a column from another dataframe df[A].

This is an example of my code

JavaScript

I tried this but it does not work:

JavaScript

Advertisement

Answer

To use assert for pandas series you can use assert_series_equal which checks that left and right Series are equal.

JavaScript

which will give you error if series values are different.

AssertionError: Series.index are different

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement