[英]Convert multiple Int64Index([], dtype='int64') in a list to a list
I have a list with int64index, I want to change it to a flat list.我有一个带有 int64index 的列表,我想将其更改为平面列表。 Can you help me with this?你能帮我解决这个问题吗? here is a simple example.这是一个简单的例子。
l = [Int64Index([518], dtype='int64'), Int64Index([599], dtype='int64'), Int64Index([614], dtype='int64')]
The output: output:
[518, 599, 614]
You should probably fix whatever process produced this in the first place, but you can get a list
of python int
objects using something like:您可能应该首先修复产生此问题的任何过程,但您可以使用以下内容获取 python int
对象的list
:
[x for idx in l for x in idx.tolist()]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.