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

Method update_info

pandas/io/pytables.py:2384–2413  ·  view source on GitHub ↗

set/update the info for this indexable with the key/value if there is a conflict raise/warn as needed

(self, info)

Source from the content-addressed store, hash-verified

2382 )
2383
2384 def update_info(self, info) -> None:
2385 """
2386 set/update the info for this indexable with the key/value
2387 if there is a conflict raise/warn as needed
2388 """
2389 for key in self._info_fields:
2390 value = getattr(self, key, None)
2391 idx = info.setdefault(self.name, {})
2392
2393 existing_value = idx.get(key)
2394 if key in idx and value is not None and existing_value != value:
2395 # frequency/name just warn
2396 if key in ["freq", "index_name"]:
2397 ws = attribute_conflict_doc % (key, existing_value, value)
2398 warnings.warn(
2399 ws, AttributeConflictWarning, stacklevel=find_stack_level()
2400 )
2401
2402 # reset
2403 idx[key] = None
2404 setattr(self, key, None)
2405
2406 else:
2407 raise ValueError(
2408 f"invalid info for [{self.name}] for [{key}], "
2409 f"existing_value [{existing_value}] conflicts with "
2410 f"new value [{value}]"
2411 )
2412 elif value is not None or existing_value is not None:
2413 idx[key] = value
2414
2415 def set_info(self, info) -> None:
2416 """set my state from the passed info"""

Callers 1

_create_axesMethod · 0.80

Calls 2

find_stack_levelFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected