Skip to content
Advertisement

How to check if all possible combinations of columns exist in dataframe (Pandas)?

I have the following dataframe

JavaScript

And I would like to check if the dataframe is a complete combination of the entries in each column. In the above dataframe this is the case. A = {1,2} B = {1,2,3} and the dataframe contains all possible combinations. Following example would result in a false.

JavaScript

The number of columns should be flexible.

Many thanks for your help!

Advertisement

Answer

JavaScript

Create a data frame with all combinations of unique values in all columns

JavaScript

Test if two dataframes contain the same elements

JavaScript

For False scenario,

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