I am trying to make a chart similar to the side by side chart on this page https://plot.ly/python/table/ . However, I want both subplots to be tables. I haven’t even gotten very close but what I have so far is below. I can’t seem to figure out how get the second table onto the figure created by FF.create_table.
Could someone help me put these both onto a single figure with the titles suggested in the commented out section?
Thanks!
data_matrix_dem = [
['Feature', 'Coeff', 'Std Err', 'P Val'],
['State Average Turnout', 0.0048, 0.000, 0.000],
['Rural-urban Continuum Code', 0.0046, 0.000, 0.000],
['Perc Less than Highschool Diploma', 0.0006, 0.000, 0.000],
['Perc with Bachelor\'s', 0.0032, 8.54e-05, 0.000],
['Unemployment Rate', 0.0041, 0.000, 0.000],
['Religion NMF Feature 1', 0.0091, 0.001, 0.000],
['Religion NMF Feature 2', 0.0063, 0.000, 0.000],
['Campaign Expenditure', -4.084e-10, 5.09e-11, 0.000],
['Cook Index', 0.4752, 0.006, 0.000],
['Change in Vote Share 2008->2012', 0.2689, 0.024, 0.000],
['1 Field Office', 0.0088, 0.002, 0.000],
['2+ Field Offices', 0.0257, 0.004, 0.000],
['Field Office - Cook Index Interaction', 0.0348, 0.017, 0.041]
]
data_matrix_rep =[
['Feature', 'Coeff', 'Std Err', 'P Val'],
['State Average Turnout', 0.0060, 0.000, 0.000],
['Rural-urban Continuum Code', 0.0044, 0.000, 0.000],
['Perc Less than Highschool Diploma', -0.0024, 0.000, 0.000],
['Perc with Bachelor\'s', 0.0025, 0.000, 0.000],
['Unemployment Rate', 0.0054, 0.000, 0.000],
['Religion NMF Feature 1', 0.0003, 0.001, 0.700],
['Religion NMF Feature 2', 0.0072, 0.001, 0.000],
['Campaign Expenditure', -4.905e-10, 6.44e-11, 0.000],
['Cook Index', -0.5827, 0.008, 0.000],
['Change in Vote Share 2008->2012', -0.0543, 0.032, 0.000],
['1 Field Office', 0.0087, 0.004, 0.025],
['2+ Field Offices', 0.0143, 0.008, 0.080],
['Field Office - Cook Index Interaction', -.1054, 0.029, 0.000]
]
table_dem = FF.create_table(data_matrix_dem)
table_dem.layout.update({'title': 'Democratic Regression<br><i>Adj R2 0.978<i>'})
table_rep = FF.create_table(data_matrix_rep)
table_rep.layout.update({'title': 'Republican Regression<br><i>Adj R2 0.982<i>'})
# fig = tools.make_subplots(rows=1, cols=2, subplot_titles=('Democratic Regression<br><i>Adj R2 0.978<i>',
# 'Republican Regression<br><i>Adj R2 0.982<i>'))
plot_url = py.plot(table_dem, filename='Dem Regression Results')
plot_url = py.plot(table_rep, filename='Rep Regression Results')