【发布时间】:2019-10-23 09:03:24
【问题描述】:
我有一个名为“数据”的嵌套字典,其中包含键(字典名称)和值(字典)。
我希望从外部字典中分离出单个字典。
这就是我如何读取 csv 文件的文件夹来制作 dicts 的字典:
#read csvs with filename as dictionary names
data= dict()
for file in files:
key = file
val = pd.read_csv(
csv_path + file + ".csv", index_col=0).to_dict(orient='dict')['values']
data[key] = val
【问题讨论】:
-
请提供样本数据。
-
你想要的输出是什么?字典列表?
-
FWIW,你可以保存一行:
data[file] = val -
我想要的输出是与字典相关联的每个键。那就是有单独的字典,每个字典都以键为名称
标签: python dictionary