parameters: (values: ArrayLike, ndim: int = 1)
return_statement: return values
docstring: Reshape if possible to have values.ndim == ndim.
docstring_summary: Reshape if possible to have values.ndim == ndim.
docstring_tokens: Reshape if possible to have values . ndim == ndim .
function: def ensure_block_shape(values: ArrayLike, ndim: int = 1) -> ArrayLike:
      """
      Reshape if possible to have values.ndim == ndim.
      """
  
      if values.ndim < ndim:
          if not is_1d_only_ea_dtype(values.dtype):
              # TODO(EA2D): https://github.com/pandas-dev/pandas/issues/23023
              # block.shape is incorrect for "2D" ExtensionArrays
              # We can't, and don't need to, reshape.
              values = cast("np.ndarray | DatetimeArray | TimedeltaArray", values)
              values = values.reshape(1, -1)
  
      return values
function_tokens: def ensure_block_shape ( values : ArrayLike , ndim : int = 1 ) -> ArrayLike : if values . ndim < ndim : if not is_1d_only_ea_dtype ( values . dtype ) : # TODO(EA2D): https://github.com/pandas-dev/pandas/issues/23023 # block.shape is incorrect for "2D" ExtensionArrays # We can't, and don't need to, reshape. values = cast ( "np.ndarray | DatetimeArray | TimedeltaArray" , values ) values = values . reshape ( 1 , - 1 ) return values