Check whether or not the `columns` parameter could be converted into a MultiIndex. Parameters ---------- columns : array-like Object which may or may not be convertible into a MultiIndex index_col : None, bool or list, optional Column or columns to use as th
(
columns: Sequence[Hashable] | MultiIndex,
index_col: bool | Sequence[int] | None = None,
)
| 1265 | |
| 1266 | |
| 1267 | def is_potential_multi_index( |
| 1268 | columns: Sequence[Hashable] | MultiIndex, |
| 1269 | index_col: bool | Sequence[int] | None = None, |
| 1270 | ) -> bool: |
| 1271 | """ |
| 1272 | Check whether or not the `columns` parameter |
| 1273 | could be converted into a MultiIndex. |
| 1274 | |
| 1275 | Parameters |
| 1276 | ---------- |
| 1277 | columns : array-like |
| 1278 | Object which may or may not be convertible into a MultiIndex |
| 1279 | index_col : None, bool or list, optional |
| 1280 | Column or columns to use as the (possibly hierarchical) index |
| 1281 | |
| 1282 | Returns |
| 1283 | ------- |
| 1284 | bool : Whether or not columns could become a MultiIndex |
| 1285 | """ |
| 1286 | if index_col is None or isinstance(index_col, bool): |
| 1287 | index_columns = set() |
| 1288 | else: |
| 1289 | index_columns = set(index_col) |
| 1290 | |
| 1291 | return bool( |
| 1292 | len(columns) |
| 1293 | and not isinstance(columns, ABCMultiIndex) |
| 1294 | and all(isinstance(c, tuple) for c in columns if c not in index_columns) |
| 1295 | ) |
| 1296 | |
| 1297 | |
| 1298 | def dedup_names( |
no outgoing calls
no test coverage detected