将2个列表与diff形状结合在一起,同时具有将它们链接到数据框架python的值

发布于 2025-02-06 14:09:04 字数 1304 浏览 1 评论 0原文

我有列表编号1:

['Limitation', 'Parameter', 'input', 'Feature', 'Dataset', 'Output', 'EvaluationMetric', 'Algorithm', 'Task', 'HyperParameter', 'Layer', 'Model', 'Operator', 'Function', 'OptimizationAlgorithm', 'ActivationFunction', 'LeakyReluFunction', 'LossFunction']

列表编号2:

['Input', 'Dataset', 'Algorithm', 'Operator', 'Task', 'HyperParameter', 'Output']

我有这些值描述这些单词之间的相似性 以及我如何制作数据框架。其中包含行作为第一个列表字符串,列作为SEC列表,以及单元格中的值

0.4
0.75
0.75
0.65
0.65
0.050000000000000044
0.25
0.25
0.5
0.6
0.75
0.7
0.75
1.0
0.75
0.4
0.6
0.75
0.5
0.75
0.7
0.65
0.6
0.09999999999999998
0.25
0.30000000000000004
0.44999999999999996
0.55
0.6
0.6
0.55
0.6
0.6
0.35
1.0
0.55
0.4
0.6
0.6
0.65
0.6
0.4
0.25
0.25
0.44999999999999996
0.65
0.7
0.65
0.75
0.65
0.7
0.4
0.65
0.65
0.6
0.7
0.6
1.0
0.65
0.25
0.25
0.30000000000000004
0.5
0.55
0.6
0.75
0.7
0.75
0.7
0.25
0.55
1.0
0.35
0.8
0.75
0.65
0.6
0.0
0.15000000000000002
0.19999999999999996
0.44999999999999996
0.35
0.75
0.4
0.44999999999999996
0.5
0.35
0.30000000000000004
0.4
0.35
1.0
0.44999999999999996
0.35
0.6
0.30000000000000004
0.050000000000000044
0.15000000000000002
0.25
0.30000000000000004
0.55
0.6
0.85
0.7
0.75
1.0
0.35
0.6
0.7
0.35
0.7
0.7
0.7
0.7
0.09999999999999998
0.25
0.25
0.5 

I have list number 1:

['Limitation', 'Parameter', 'input', 'Feature', 'Dataset', 'Output', 'EvaluationMetric', 'Algorithm', 'Task', 'HyperParameter', 'Layer', 'Model', 'Operator', 'Function', 'OptimizationAlgorithm', 'ActivationFunction', 'LeakyReluFunction', 'LossFunction']

list number2:

['Input', 'Dataset', 'Algorithm', 'Operator', 'Task', 'HyperParameter', 'Output']

And I have these values that describe the similarity between these words
and how could I make a data frame. that contains rows as the first list strings, columns as the sec list, and the values in the cells

0.4
0.75
0.75
0.65
0.65
0.050000000000000044
0.25
0.25
0.5
0.6
0.75
0.7
0.75
1.0
0.75
0.4
0.6
0.75
0.5
0.75
0.7
0.65
0.6
0.09999999999999998
0.25
0.30000000000000004
0.44999999999999996
0.55
0.6
0.6
0.55
0.6
0.6
0.35
1.0
0.55
0.4
0.6
0.6
0.65
0.6
0.4
0.25
0.25
0.44999999999999996
0.65
0.7
0.65
0.75
0.65
0.7
0.4
0.65
0.65
0.6
0.7
0.6
1.0
0.65
0.25
0.25
0.30000000000000004
0.5
0.55
0.6
0.75
0.7
0.75
0.7
0.25
0.55
1.0
0.35
0.8
0.75
0.65
0.6
0.0
0.15000000000000002
0.19999999999999996
0.44999999999999996
0.35
0.75
0.4
0.44999999999999996
0.5
0.35
0.30000000000000004
0.4
0.35
1.0
0.44999999999999996
0.35
0.6
0.30000000000000004
0.050000000000000044
0.15000000000000002
0.25
0.30000000000000004
0.55
0.6
0.85
0.7
0.75
1.0
0.35
0.6
0.7
0.35
0.7
0.7
0.7
0.7
0.09999999999999998
0.25
0.25
0.5 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2025-02-13 14:09:04

您的数据具有117个值,并且您有一个18x7矩阵(行*列),需要126个值。

import numpy as np
import pandas as pd


your_data = '0.4 0.75 0.75 0.65 0.65 0.050000000000000044 0.25 0.25 0.5 0.6 0.75 0.7 0.75 1.0 0.75 0.4 0.6 0.75 0.5 0.75 0.7 0.65 0.6 0.09999999999999998 0.25 0.30000000000000004 0.44999999999999996 0.55 0.6 0.6 0.55 0.6 0.6 0.35 1.0 0.55 0.4 0.6 0.6 0.65 0.6 0.4 0.25 0.25 0.44999999999999996 0.65 0.7 0.65 0.75 0.65 0.7 0.4 0.65 0.65 0.6 0.7 0.6 1.0 0.65 0.25 0.25 0.30000000000000004 0.5 0.55 0.6 0.75 0.7 0.75 0.7 0.25 0.55 1.0 0.35 0.8 0.75 0.65 0.6 0.0 0.15000000000000002 0.19999999999999996 0.44999999999999996 0.35 0.75 0.4 0.44999999999999996 0.5 0.35 0.30000000000000004 0.4 0.35 1.0 0.44999999999999996 0.35 0.6 0.30000000000000004 0.050000000000000044 0.15000000000000002 0.25 0.30000000000000004 0.55 0.6 0.85 0.7 0.75 1.0 0.35 0.6 0.7 0.35 0.7 0.7 0.7 0.7 0.09999999999999998 0.25 0.25 0.5'
values = your_data.split(' ')

for i in range(9):
    values.append(np.nan)

data_matrix = np.split(np.array(values), (18))


list1 = ['Limitation', 'Parameter', 'input', 'Feature', 'Dataset', 'Output', 'EvaluationMetric', 'Algorithm', 'Task', 'HyperParameter', 'Layer', 'Model', 'Operator', 'Function', 'OptimizationAlgorithm', 'ActivationFunction', 'LeakyReluFunction', 'LossFunction']

list2 =['Input', 'Dataset', 'Algorithm', 'Operator', 'Task', 'HyperParameter', 'Output']

df = pd.DataFrame(index=list1, columns=list2, data=data_matrix)
print(df)

Your data have 117 values, and you have a 18x7 matrix (rows*columns) that requires 126 values.. filling this with NaN you could

import numpy as np
import pandas as pd


your_data = '0.4 0.75 0.75 0.65 0.65 0.050000000000000044 0.25 0.25 0.5 0.6 0.75 0.7 0.75 1.0 0.75 0.4 0.6 0.75 0.5 0.75 0.7 0.65 0.6 0.09999999999999998 0.25 0.30000000000000004 0.44999999999999996 0.55 0.6 0.6 0.55 0.6 0.6 0.35 1.0 0.55 0.4 0.6 0.6 0.65 0.6 0.4 0.25 0.25 0.44999999999999996 0.65 0.7 0.65 0.75 0.65 0.7 0.4 0.65 0.65 0.6 0.7 0.6 1.0 0.65 0.25 0.25 0.30000000000000004 0.5 0.55 0.6 0.75 0.7 0.75 0.7 0.25 0.55 1.0 0.35 0.8 0.75 0.65 0.6 0.0 0.15000000000000002 0.19999999999999996 0.44999999999999996 0.35 0.75 0.4 0.44999999999999996 0.5 0.35 0.30000000000000004 0.4 0.35 1.0 0.44999999999999996 0.35 0.6 0.30000000000000004 0.050000000000000044 0.15000000000000002 0.25 0.30000000000000004 0.55 0.6 0.85 0.7 0.75 1.0 0.35 0.6 0.7 0.35 0.7 0.7 0.7 0.7 0.09999999999999998 0.25 0.25 0.5'
values = your_data.split(' ')

for i in range(9):
    values.append(np.nan)

data_matrix = np.split(np.array(values), (18))


list1 = ['Limitation', 'Parameter', 'input', 'Feature', 'Dataset', 'Output', 'EvaluationMetric', 'Algorithm', 'Task', 'HyperParameter', 'Layer', 'Model', 'Operator', 'Function', 'OptimizationAlgorithm', 'ActivationFunction', 'LeakyReluFunction', 'LossFunction']

list2 =['Input', 'Dataset', 'Algorithm', 'Operator', 'Task', 'HyperParameter', 'Output']

df = pd.DataFrame(index=list1, columns=list2, data=data_matrix)
print(df)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文