Explain Array Split in Numpy?

Array splitting can be vertical, horizontal, or depth-wise. We can use functions hsplit(), vsplit() and dsplit() respectively for the same . We can split arrays into arrays of the same shape by indicating the position after which the split should occur.

  • Horizontal splitting: The ‘hsplit()’ function splits an array along axis parameter = 1. ‘numpy.hsplit’ is equivalent to ‘split’ with axis parameter = 1, the array is always splitted along the second axis regardless of the array dimension. This function split an array into multiple sub-arrays horizontally (column-wise).

numpy.hsplit(ary, indices_or_sections)

  • Vertical splitting: The ‘vsplit()’ function splits an array along axis parameter = 0.‘numpy.vsplit’ is equivalent to ‘split’ with axis parameter = 0. This function split an array into multiple sub-arrays vertically (row-wise).

numpy.vsplit(ary, indices_or_sections)