Skip to content

fill_none with empty array of specific Record type #3252

Answered by jpivarski
qibin2020 asked this question in Q&A
Discussion options

You must be logged in to vote

It becomes an option-type because it might need to insert None values to increase length-0 or length-1 lists to length-2.

>>> example = ak.Array([[[{"px": 1, "py": 2, "pz": 3}] * 2]] * 100)
>>> print(example.type)
100 * var * var * {px: int64, py: int64, pz: int64}

These lists are already length-2, but the type doesn't say that: the type is "var" (ragged). When you set target=2, it will increase any lists to reach length-2 by inserting None values, hence the option-type. The clip=2 just ensures that any lists longer than 2 will be clipped. (The axis=2 is the depth, which, in this case, is also coincidentally 2.)

>>> print(ak.pad_none(example, target=2, clip=2, axis=2).type)
100 * var * 2 *

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@qibin2020
Comment options

@jpivarski
Comment options

Answer selected by qibin2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants