简体   繁体   中英

How to export dictionary with multiple values in Excel file

I have a dictionary with multiple values to a key. For ex:

dict = {u'Days': [u'Monday', u'Tuesday', u'Wednesday', u'Thursday'],u'Temp_value':[54,56,57,45], u'Level_value': [30,34,35,36] and so on...}

I want to export this Data to excel in the below-mentioned formet.

Column 1   Column 2      column 3      so on...
Days       Temp_value    Level_value
Monday     54            30
Tuesday    56            34
Wednesday  57            35
Thursday   45            36

How can I do that?

Use pandas

import pandas as pd
df = pd.DataFrame(your_dict)
df.to_excel('your_file.xlsx', index=False)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM