Considering a dataframe with the following shape:
label method args
Cluster 0 relayout ['shapes', 1]
Cluster 1 relayout ['shapes', 3]
Cluster 2 relayout ['shapes', 4]
I want to to create a dictionary that looks like this:
{'buttons': [
{'label': 'Cluster 0', 'method': 'relayout', 'args': ['shapes', 1]},
{'label': 'Cluster 1', 'method': 'relayout', 'args': ['shapes', 3]},
{'label': 'Cluster 2', 'method': 'relayout', 'args': ['shapes', 4]},
]}
Using df.to_dict
res = {'buttons': df.to_dict(orient='records')}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.