numpy shorthand for taking jagged slice

前端 未结 3 423
萌比男神i
萌比男神i 2020-12-21 02:22

I have an operation that I\'m doing commonly which I\'m calling a \"jagged-slice\" because I don\'t know the real name for it. It\'s best explained by example:



        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-21 02:57

    I think that your current method is probably the best way.

    You can also use choose for this kind of selection. This is syntactically clearer, but is trickier to get right and potentially more limited. The equivalent with this method would be:

    entries_of_interest.choose(a.T)
    

提交回复
热议问题