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

Method _ensure_array

pandas/core/indexes/base.py:595–610  ·  view source on GitHub ↗

Ensure we have a valid array to pass to _simple_new.

(cls, data, dtype, copy: bool)

Source from the content-addressed store, hash-verified

593
594 @classmethod
595 def _ensure_array(cls, data, dtype, copy: bool):
596 """
597 Ensure we have a valid array to pass to _simple_new.
598 """
599 if data.ndim > 1:
600 # GH#13601, GH#20285, GH#27125
601 raise ValueError("Index data must be 1-dimensional")
602 elif dtype == np.float16:
603 # float16 not supported (no indexing engine)
604 raise NotImplementedError("float16 indexes are not supported")
605
606 if copy:
607 # asarray_tuplesafe does not always copy underlying data,
608 # so need to make sure that this happens
609 data = data.copy()
610 return data
611
612 @final
613 @classmethod

Callers 1

__new__Method · 0.80

Calls 1

copyMethod · 0.45

Tested by

no test coverage detected