【发布时间】:2017-04-16 17:52:41
【问题描述】:
我有一个字典,其键“组”的第一个元素包含一个数组列表。
stump['Groups'][0]
[array(['a', 65000, 0], dtype=object),
array(['a', 95000, 1], dtype=object),
array(['b', 78000, 1], dtype=object),
array(['b', 19000, 1], dtype=object)]
我想对每一行的第三列进行切片并对它们进行一些操作。 所以第三列值将是 [0,1,1,1]。
stump['Groups'][0][:]
#results in the whole list
[array(['a', 65000, 0], dtype=object),
array(['a', 95000, 1], dtype=object),
array(['b', 78000, 1], dtype=object),
array(['b', 19000, 1], dtype=object)]
但是,在 [:] 前面添加另一个索引器/切片器,只会对该列表的一部分进行切片。
无论如何要在没有循环的情况下做到这一点?
谢谢。
【问题讨论】: