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

Function _new_Index

pandas/core/indexes/base.py:294–320  ·  view source on GitHub ↗

This is called upon unpickling, rather than the default which doesn't have arguments and breaks __new__.

(cls, d)

Source from the content-addressed store, hash-verified

292
293
294def _new_Index(cls, d):
295 """
296 This is called upon unpickling, rather than the default which doesn't
297 have arguments and breaks __new__.
298 """
299 # required for backward compat, because PI can't be instantiated with
300 # ordinals through __new__ GH #13277
301 d["copy"] = False
302 if issubclass(cls, ABCPeriodIndex):
303 from pandas.core.indexes.period import _new_PeriodIndex
304
305 return _new_PeriodIndex(cls, **d)
306
307 if issubclass(cls, ABCMultiIndex):
308 if "labels" in d and "codes" not in d:
309 # GH#23752 "labels" kwarg has been replaced with "codes"
310 d["codes"] = d.pop("labels")
311
312 # Since this was a valid MultiIndex at pickle-time, we don't need to
313 # check validty at un-pickle time.
314 d["verify_integrity"] = False
315
316 elif "dtype" not in d and "data" in d:
317 # Prevent Index.__new__ from conducting inference;
318 # "data" key not in RangeIndex
319 d["dtype"] = d["data"].dtype
320 return cls.__new__(cls, **d)
321
322
323@set_module("pandas")

Callers

nothing calls this directly

Calls 3

_new_PeriodIndexFunction · 0.90
popMethod · 0.45
__new__Method · 0.45

Tested by

no test coverage detected