The code below allows me to determine what the most common main dish and the most common method of preparation for the most common main dish, for each US Region. It uses data obtained from 'thanksgiving-2015-poll-data.csv' which can be found on (GitHub).
I believe that a pivot_table might offer a more efficient method of getting the same information, but I can not figure out how to do so. Can anyone offer any insight? Here's the code I used to get this information which works but I feel is not the best (fastest) method for doing so.
import pandas as pd data = pd.read_csv('thanksgiving-2015-poll-data.csv', encoding="Latin-1") regions = data['US Region'].value_counts().keys() main_dish = data['What is typically the main dish at your Thanksgiving dinner?'] main_dish_prep = data['How is the main dish typically cooked?'] regional_entire_meal_data_rows =  for region in regions: is_in_region = data['US Region'] == region most_common_regional_dish = main_dish[is_in_region].value_counts().keys().tolist() is_region_and_most_common_dish = (is_in_region) & (main_dish == most_common_regional_dish) most_common_regional_dish_prep_type = main_dish_prep[is_region_and_most_common_dish].value_counts().keys().tolist() regional_entire_meal_data_rows.append((region, most_common_regional_dish, most_common_regional_dish_prep_type)) labels = ['US Region', 'Most Common Main Dish', 'Most Common Prep Type for Main Dish'] regional_main_dish_data = pd.DataFrame(regional_entire_meal_data_rows, columns=labels) full_meal_message = '''\n\nThe table below shows a breakdown of the most common full Thanksgiving meal broken down by region.\n''' print(full_meal_message) print(regional_main_dish_data)