ak.str.center
-------------

.. py:module: ak.str.center

Defined in `awkward.operations.str.akstr_center <https://github.com/scikit-hep/awkward/blob/3d14f2e74c7b6d99b09e436f90de4722f5959548/src/awkward/operations/str/akstr_center.py>`__ on `line 13 <https://github.com/scikit-hep/awkward/blob/3d14f2e74c7b6d99b09e436f90de4722f5959548/src/awkward/operations/str/akstr_center.py#L13>`__.

.. py:function:: ak.str.center(array, width, padding=' ', *, highlevel=True, behavior=None, attrs=None)


    :param array: Array-like data (anything :py:obj:`ak.to_layout` recognizes).
    :param width: Desired string length.
    :type width: int
    :param padding: What to pad the string with. Should be one
                codepoint or byte.
    :type padding: str or bytes
    :param highlevel: If True, return an :py:obj:`ak.Array`; otherwise, return
                  a low-level :py:obj:`ak.contents.Content` subclass.
    :type highlevel: bool
    :param behavior: Custom :py:obj:`ak.behavior` for the output array, if
                 high-level.
    :type behavior: None or dict
    :param attrs: Custom attributes for the output array, if
              high-level.
    :type attrs: None or dict

Replaces any string or bytestring-valued data with centered
strings/bytestrings of a given ``width``, padding both sides with the given
``padding`` codepoint or byte.

If the data are strings, ``width`` is measured in codepoints and ``padding``
must be one codepoint.

If the data are bytestrings, ``width`` is measured in bytes and ``padding``
must be one byte.

Note: this function does not raise an error if the ``array`` does not
contain any string or bytestring data.

Requires the pyarrow library and calls
`pyarrow.compute.utf8_center <https://arrow.apache.org/docs/python/generated/pyarrow.compute.utf8_center.html>`__
or
`pyarrow.compute.ascii_center <https://arrow.apache.org/docs/python/generated/pyarrow.compute.ascii_center.html>`__
on strings and bytestrings, respectively.