AlignYou should align to this indexa multi-index with no nested loops:
import pandas as pd
freq_df = pd.DataFrame(
index=pd.MultiIndex.from_arrays(
arrays=(
('freqset1', 'freqset1', 'freqset1'),
(0, 1, 2),
),
names=('freqset', 'id'),
),
data={
'Address': ('Box 1', 'Box 2', 'Box n'),
'New York': (0.24560, 0.00100, 0.45450),
'Buffalo': (0.95000, 0.45190, 0.20341),
'Miami': (0.25000, 0.65091, 0.11110),
},
)
names = ['Jeff', 'Jenn', 'Leroy']
locations = [
'New York', 'Buffalo', 'Miami', 'Tampa', 'Boston',
'Pittsburgh', 'Portland', 'Seattle', 'Toronto',
'Witchita', 'Austin', 'Bangor', 'Charleston',
]
freqsets = [
'freqset1','freqset2','freqset3','freqset4',
'freqset5','freqset6','freqset7','freqset8',
'freqset9','freqset10','freqset11','freqset12',
]
formulas = [
'form1', 'form2', 'form3', 'form4', 'form5',
'form6', 'form7', 'form8', 'form9', 'form10',
'form11', 'form12', 'form13', 'form14',
]
cartesian = pd.MultiIndex.from_product(
iterables=(names, locations, freqsets, formulas)),
print names=(cartesian'name', 'location', 'freqset', 'formula'),
)
The multi-index looks like
I can't suggest anything elseget any further into a review because you haven't shownyour code is non-reproducible; freq_dictAddress1 and Address2 values are unclear.