Python 具有列表的列表的数据操纵器

Python 具有列表的列表的数据操纵器,python,pandas,nested-lists,evaluation,Python,Pandas,Nested Lists,Evaluation,我已经问了好几次这个问题,但方式不对,所以我决定从一开始就问: 我做了聚类。我发现了两个集群 clusters = [[cluster 1 data],[cluster 2 data]] 集群= [[ ordinal id_easy latitude longitude 1226 1 141 11.1024 7.7498 1229 4 141 11.1076 7.7563,

我已经问了好几次这个问题,但方式不对,所以我决定从一开始就问:

我做了聚类。我发现了两个集群

clusters = [[cluster 1 data],[cluster 2 data]]
集群=

    [[      ordinal  id_easy  latitude  longitude
      1226        1      141   11.1024     7.7498
      1229        4      141   11.1076     7.7563,
            ordinal  id_easy  latitude  longitude
      3792        1    22087   11.1134     7.7145,
            ordinal  id_easy  latitude  longitude
      4249        1    22079   11.0016     7.5629
      4250        2    22079   11.0026     7.5632],
     [      ordinal  id_easy  latitude  longitude
      3669        1    19421   11.0760     7.6786
      3696       28    19421   11.0287     7.6679,
            ordinal  id_easy  latitude  longitude
      4172        1    19330   11.0430     7.6699
      4191       20    19330   11.0020     7.6530,
            ordinal  id_easy  latitude  longitude
      1580        1    23140   11.0635     7.5231
      1583        4    23140   11.0646     7.5194]]
完成后,我需要评估我的模型。但要做到这一点,我需要准备数据,这是一个问题。我用sklearn计算了每个簇的中心。我想把每个中心与经度和纬度的每一对进行比较。只工作!带有显示的列

为此,我需要按以下方式准备数据:

完成此操作后,如何调用与群集0相关的数据

我需要能够调用集群,它会给我一个有2列的数据帧。因为我会比较每个集群的值和它的中心。

试试看concat


几乎完美!一个问题:如何调用与群集0相关的数据?@Mamed使用df.loc[0]
 l= [pd.concat(x) for x in clusters ]
 pd.concat(l,keys=range(len(l)))