Search code examples
uproot

zero padding variable length of array in uproot


I need a memory efficient way to zero pad uneven array size per event according to largest array in a tree. Is there any way available to do that in uproot?


Solution

  • jagged_array.pad(max_length).fillna(0)
    

    If you need to find the maximum, you can

    jagged_array.counts.max()
    

    If you then need to turn it into pure NumPy, use regular().