For example, if
list1=[1,2,3]
list2=[[1,1,1],[2,2,2],[3,3,3]]
I'd like to create a dictionary like
dict1={'1':[1,1,1],'2':[2,2,2],'3':[3,3,3]}
How can I realize it through loops? I tried
dict1=dict().fromkeys(list1)
for i in range(len(list1)):
dict1['i']=list2[i]
But I failed, so is there anyone can help me deal with this problem? One more question, if I firstly create an empty dataframe, df1
df1=pd.DataFrame()
and I hope use the elements in list1 as columns' name of df1. How can I realize it?
Thanks for your assistance!
dict(zip(map(str, list1),list2))