how to dynamically choose row labels using tabulate in python -


i have dictionary keys strings , values lists of integers. created follows:

table_dict_of_lists = {} label in return_dict_keys:     temp_list = []     dict_list in stats_list_dict_list:         temp_list.append(len(dict_list[label]))     table_dict_of_lists[label] = temp_list 

when run following:

for k, v in table_dict_of_lists.iteritems():     print k, v 

i following:

agentsgtx [566, 0, 0, 69, 134] pure_user_dict [11818, 0, 0, 627, 1910] inv_a_id_user_id [857, 0, 0, 73, 135] user_email_id_dict [18005, 0, 0, 800, 2669] ruurl_set [1288, 0, 0, 107, 247] user_id_invite_dict [9772, 0, 0, 473, 1578] pure_users_with_agents_dict [11060, 0, 0, 580, 1825] user_id_email_dict [18066, 0, 0, 800, 2682] 

this in service of trying dynamically print data table using tabulate.

i've got:

first_table = table_dict_of_lists f.write(tabulate(first_table, headers = "keys")) 

needless say, puts the keys column headers. i've looked here don't see answer.

how keys label rows?

the documentation never seems suggest row headers supported in library. here's possible workaround @ least tabulate correctly:

f.write(tabulate(([k] + v k, v in first_table.iteritems()))) 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -