MCPcopy Create free account
hub / github.com/apache/arrow / _index_level_name

Function _index_level_name

python/pyarrow/pandas_compat.py:365–384  ·  view source on GitHub ↗

Return the name of an index level or a default name if `index.name` is None or is already a column name. Parameters ---------- index : pandas.Index i : int Returns ------- name : str

(index, i, column_names)

Source from the content-addressed store, hash-verified

363
364
365def _index_level_name(index, i, column_names):
366 """Return the name of an index level or a default name if `index.name` is
367 None or is already a column name.
368
369 Parameters
370 ----------
371 index : pandas.Index
372 i : int
373
374 Returns
375 -------
376 name : str
377 """
378 if index.name is not None and index.name not in column_names:
379 return _column_name_to_strings(index.name)
380 else:
381 j = i
382 while f'__index_level_{j:d}__' in column_names:
383 j += 1
384 return f'__index_level_{j:d}__'
385
386
387def _get_columns_to_convert(df, schema, preserve_index, columns):

Callers 1

_get_columns_to_convertFunction · 0.85

Calls 1

_column_name_to_stringsFunction · 0.85

Tested by

no test coverage detected