Question: Define a python function that checks whether a given sample of 5 cards from the cards data frame is the two pairs hand. import pandas

Define a python function that checks whether a given sample of 5 cards from the cards data frame is the "two pairs" hand. Define a python function that checks whether a given sample of 5cards from the cards data frame is the "two pairs" hand. import

import pandas as pd df - pd.read_csv('cards.csv') df.head(5) 21: color suit face 0 1 black black clubA club 2 2 3 4 black black black club club club 3 4 5 Define a python function that checks whether a given sample of 5 cards from the cards data frame is the "two pairs" hand. It should return the value True if the sample is a "two pairs" sample, and False if not. Show that your function works by testing on the test cases given below. def is_two_pair_hand(df, var='face'); return "True" else: return "False" # test cases - run this cell to create them test1 = pd.DataFrame({'color': ['red', 'black', 'black', 'black', 'red'], 'suit': ['heart', 'club', 'spade', 'club', 'diamond' ], 'face': ['2', 'Q', '2','K','K']}) test2 = pd.DataFrame({'color': ['red', 'black', 'black', 'black', 'red'], suit': ['heart', 'club', 'spade', 'club', 'diamond' ], 'face': ['A', 'Q', '2','K','K']}) test3 = pd.DataFrame({'color': ['red', 'black', 'black', 'black', 'red'], 'suit': ['heart', 'club', 'spade', 'club', 'diamond'], 'face': ['2', '2', '2','K','K']})

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!