I have two Python Pandas dataframes A, B, with the same columns (obviously with different data). I want to check A is a subset of B, that is, all rows of A are contained in
You also can try:
ex = pd.DataFrame({"col1": ["banana", "tomato", "apple"],
"col2": ["cat", "dog", "kangoo"],
"col3": ["tv", "phone", "ps4"]})
ex2 = ex.iloc[0:2]
ex2.isin(ex).all().all()
It returns True
If you try to switch some values such as tv and phone you get a False value
ex2 = pd.DataFrame({"col1": ["banana", "tomato"],
"col2": ["cat", "dog"],
"col3": ["phone", "tv"]})
ex2.isin(ex).all().all()
>> False