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

Method _clean_mapping

pandas/io/parsers/base_parser.py:306–321  ·  view source on GitHub ↗

converts col numbers to names

(self, mapping)

Source from the content-addressed store, hash-verified

304
305 @final
306 def _clean_mapping(self, mapping):
307 """converts col numbers to names"""
308 if not isinstance(mapping, dict):
309 return mapping
310 clean = {}
311 # for mypy
312 assert self.orig_names is not None
313
314 for col, v in mapping.items():
315 if isinstance(col, int) and col not in self.orig_names:
316 col = self.orig_names[col]
317 clean[col] = v
318 if isinstance(mapping, defaultdict):
319 remaining_cols = set(self.orig_names) - set(clean.keys())
320 clean.update({col: mapping[col] for col in remaining_cols})
321 return clean
322
323 @final
324 def _agg_index(self, index) -> Index:

Callers 2

_agg_indexMethod · 0.95
_convert_dataMethod · 0.80

Calls 3

itemsMethod · 0.45
keysMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected