MCPcopy
hub / github.com/pandas-dev/pandas / _ensure_2d

Function _ensure_2d

pandas/core/internals/construction.py:542–550  ·  view source on GitHub ↗

Reshape 1D values, raise on anything else other than 2D.

(values: np.ndarray)

Source from the content-addressed store, hash-verified

540
541
542def _ensure_2d(values: np.ndarray) -> np.ndarray:
543 """
544 Reshape 1D values, raise on anything else other than 2D.
545 """
546 if values.ndim == 1:
547 values = values.reshape((values.shape[0], 1))
548 elif values.ndim != 2:
549 raise ValueError(f"Must pass 2-d input. shape={values.shape}")
550 return values
551
552
553def _homogenize(

Callers 2

ndarray_to_mgrFunction · 0.85
_prep_ndarraylikeFunction · 0.85

Calls 1

reshapeMethod · 0.45

Tested by

no test coverage detected