October 2019
Beginner to intermediate
674 pages
16h 43m
English
A dictionary of tuples can create a structured DataFrame with hierarchically indexed rows and columns. The following is a dictionary of tuples:
salesData = {("2012", "Q1"): {("North", "Brand A"): 100, ("North", "Brand B"): 80, ("South", "Brand A"): 25, ("South", "Brand B"): 40},("2012", "Q2"): {("North", "Brand A"): 30, ("South", "Brand B"): 50},("2013", "Q1"): {("North", "Brand A"): 80, ("North", "Brand B"): 10, ("South", "Brand B"): 25},("2013", "Q2"): {("North", "Brand A"): 70, ("North", "Brand B"): 50, ("South", "Brand A"): 35, ("South", "Brand B"): 40}}
Instead of a regular key-value pair, the key is a tuple with two values denoting two levels in the row index, and the value is a dictionary ...
Read now
Unlock full access