def to_0d_object_array(
    value: object,
) -> NDArray[np.object_]:
    """Given a value, wrap it in a 0-D numpy.ndarray with dtype=object."""
    result = np.empty((), dtype=object)
    result[()] = value
    return result
Given a value, wrap it in a 0-D numpy.ndarray with dtype=object.
xarray/namedarray/utils.py