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

Method _validate_codes

pandas/core/indexes/multi.py:343–362  ·  view source on GitHub ↗

Reassign code values as -1 if their corresponding levels are NaN. Parameters ---------- code : Index Code to reassign. level : np.ndarray Level to check for missing values (NaN, NaT, None). Returns ------- new

(self, level: Index, code: np.ndarray)

Source from the content-addressed store, hash-verified

341 return result
342
343 def _validate_codes(self, level: Index, code: np.ndarray) -> np.ndarray:
344 """
345 Reassign code values as -1 if their corresponding levels are NaN.
346
347 Parameters
348 ----------
349 code : Index
350 Code to reassign.
351 level : np.ndarray
352 Level to check for missing values (NaN, NaT, None).
353
354 Returns
355 -------
356 new code where code value = -1 if it corresponds
357 to a level with missing values (NaN, NaT, None).
358 """
359 null_mask = isna(level)
360 if np.any(null_mask):
361 code = np.where(null_mask[code], -1, code)
362 return code
363
364 def _verify_integrity(
365 self,

Callers 1

_verify_integrityMethod · 0.95

Calls 3

isnaFunction · 0.90
anyMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected