【问题标题】:Convert multiple Int64Index([], dtype='int64') in a list to a list将列表中的多个 Int64Index([], dtype=\'int64\') 转换为列表
【发布时间】:2022-08-03 00:07:04
【问题描述】:

我有一个带有 int64index 的列表,我想将其更改为平面列表。你能帮我解决这个问题吗?这是一个简单的例子。

l = [Int64Index([518], dtype=\'int64\'), Int64Index([599], dtype=\'int64\'), Int64Index([614], dtype=\'int64\')]

输出:

[518, 599, 614]

    标签: python pandas


    【解决方案1】:

    你应该可能使固定不管什么过程首先产生了这个,但是你可以使用类似的东西得到一个 python int 对象的list

    [x for idx in l for x in idx.tolist()]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-04
      • 2013-01-06
      • 2020-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 2020-05-10
      相关资源
      最近更新 更多