Replies: 2 comments 4 replies
-
The >>> C.show(type=True)
type: 3 * var * (
{
a1: int64,
a2: int64
},
{
a1: int64,
a2: int64
}
)
[[({a1: 1, a2: 11}, {a1: 2, a2: 21})],
[({a1: 3, a2: 31}, {a1: 4, a2: 41}), ({...}, ...), ({a1: 4, ...}, {...})],
[]] The If you want to pull out the first slot of the resulting tuple, you can use a string representing the index, e.g. >>> C[0, 0, "0"]
{a1: 1, a2: 11} If you would like to name these fields, and obtain a record instead of a tuple, you can pass a >>> C = ak.combinations(R, 2, fields=["first", "second"])
>>> C.show(type=True)
type: 3 * var * {
first: {
a1: int64,
a2: int64
},
second: {
a1: int64,
a2: int64
}
}
[[{first: {a1: 1, a2: 11}, second: {a1: 2, ...}}],
[{first: {a1: 3, a2: 31}, second: {a1: 4, ...}}, ..., {first: {...}, ...}],
[]] |
Beta Was this translation helpful? Give feedback.
-
Thanks. It is clear to me now that
Is there a way to find all combinations where at least one "a1" value is > 2? I can write code that does this check for each combination but I am wondering if it is possible to do it as a vectorized operation, making it more efficient. Thanks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please see the following code where I am using "zip" to build a record and then create combinations.
I see the following response when I run this code:
It is possible that I am missing something here but I thought that "combinations()" should add an extra dimension to the array as it generates list of tuples. But from the error message above, it seems that a tuple of records is also treated as a record. Is that correct?
I also see a "tolist()" method on the record and perhaps that will convert the combination tuple to a list but would it be possible to convert all record tuples to an extra dimension (axis)? I am hoping that this would allow me to create a mask such as "> 0.5" or something like that against entire axis.
I apologize if I haven't explained the issue properly. Any help is appreciated.
Thanks,
Raghu
Beta Was this translation helpful? Give feedback.
All reactions