我有两个职能。第一个功能的输出是一组数据。此数据的模板是两个数组x和y。我按键显示数据。为此,我为每个键都有一组数组x和y。
key=1
x1= [1549546516, 1549546526, 1549546541, 1549546542, 1549546558, 1549546559, 1549546560, 1549546594, 1549546600, 1549546606]
y1= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
key=2
x1= [1549546515, 1549546547, 1549546578, 1549546590, 1549546596, 1549546598, 1549546604, 1549546621, 1549546623, 1549546626, 1549546648, 1549546685]
y1= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
x2= [1549546607]
y2= [1]
我尝试通过密钥附加我的数据。之后,我还要循环每个键的数据并绘制其直方图。我希望这很清楚。
答案 0 :(得分:0)
要解决问题的第一部分,即结构化数据,并假设我读过要问的内容,建议您采用dict()方法。这将为您提供数据及其键的简单界面,例如:
{
"example1":{
"x1": [1549546516, 1549546526, 1549546541, 1549546542, 1549546558, 1549546559, 1549546560, 1549546594, 1549546600, 1549546606],
"y1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]},
"example2":
{
"x1": [1549546515, 1549546547, 1549546578, 1549546590, 1549546596, 1549546598, 1549546604, 1549546621, 1549546623, 1549546626, 1549546648, 1549546685],
"y1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
"x2": [1549546607],
"y2": [1]}}