我有一个从一个看起来像这样的循环生成的字典:
dict_items([('cm_Classification0.1', [FP 16
TP 13
TN 1
Name: cm_Classification0.1, dtype: int64]), ('cm_Classification0.2', [TP 13
FP 12
TN 5
Name: cm_Classification0.2, dtype: int64]), ('cm_Classification0.3', [TP 12
FP 10
TN 7
FN 1
Name: cm_Classification0.3, dtype: int64]), ('cm_Classification0.4', [TP 11
TN 9
FP 8
FN 2
Name: cm_Classification0.4, dtype: int64]), ('cm_Classification0.5', [TN 11
TP 9
FP 6
FN 4
Name: cm_Classification0.5, dtype: int64]), ('cm_Classification0.6', [TN 13
TP 8
FN 5
FP 4
Name: cm_Classification0.6, dtype: int64]), ('cm_Classification0.7', [TN 15
FN 7
TP 6
FP 2
Name: cm_Classification0.7, dtype: int64]), ('cm_Classification0.8', [TN 16
FN 9
TP 4
FP 1
Name: cm_Classification0.8, dtype: int64]), ('cm_Classification0.9', [TN 17
FN 12
TP 1
Name: cm_Classification0.9, dtype: int64])])
我需要一个人来解决如何将其放入具有以下列的数据框中:cm_Classification#
, FN
, FP
, TP
, TN
。我已经尝试过了,pd.DataFrame(list(values.items()))
但它会返回一个数据框,其中包含一列中的名称,然后是下一列中每个整数的列表。
如果有任何帮助,这是生成字典的循环:
classification_columns = question_two_partc.columns[3:12]
values = {column: list() for column in classification_columns}
for column in question_two_partc[classification_columns]:
values[column].append(question_two_partc[column].value_counts())
有人可以帮我吗?对不起,混乱!让我知道是否有任何进一步的信息可能会有所帮助!