Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions