Append to multiple tables Parameters ---------- d : a dict of table_name to table_columns, None is acceptable as the values of one node (this will get all the remaining columns) value : a pandas object selector : a string that designates
(
self,
d: dict,
value,
selector,
data_columns=None,
axes=None,
dropna: bool = False,
**kwargs,
)
| 1416 | ) |
| 1417 | |
| 1418 | def append_to_multiple( |
| 1419 | self, |
| 1420 | d: dict, |
| 1421 | value, |
| 1422 | selector, |
| 1423 | data_columns=None, |
| 1424 | axes=None, |
| 1425 | dropna: bool = False, |
| 1426 | **kwargs, |
| 1427 | ) -> None: |
| 1428 | """ |
| 1429 | Append to multiple tables |
| 1430 | |
| 1431 | Parameters |
| 1432 | ---------- |
| 1433 | d : a dict of table_name to table_columns, None is acceptable as the |
| 1434 | values of one node (this will get all the remaining columns) |
| 1435 | value : a pandas object |
| 1436 | selector : a string that designates the indexable table; all of its |
| 1437 | columns will be designed as data_columns, unless data_columns is |
| 1438 | passed, in which case these are used |
| 1439 | data_columns : list of columns to create as data columns, or True to |
| 1440 | use all columns |
| 1441 | dropna : if evaluates to True, drop rows from all tables if any single |
| 1442 | row in each table has all NaN. Default False. |
| 1443 | |
| 1444 | Notes |
| 1445 | ----- |
| 1446 | axes parameter is currently not accepted |
| 1447 | |
| 1448 | """ |
| 1449 | if axes is not None: |
| 1450 | raise TypeError( |
| 1451 | "axes is currently not accepted as a parameter to append_to_multiple; " |
| 1452 | "you can create the tables independently instead" |
| 1453 | ) |
| 1454 | |
| 1455 | if not isinstance(d, dict): |
| 1456 | raise ValueError( |
| 1457 | "append_to_multiple must have a dictionary specified as the " |
| 1458 | "way to split the value" |
| 1459 | ) |
| 1460 | |
| 1461 | if selector not in d: |
| 1462 | raise ValueError( |
| 1463 | "append_to_multiple requires a selector that is in passed dict" |
| 1464 | ) |
| 1465 | |
| 1466 | # figure out the splitting axis (the non_index_axis) |
| 1467 | axis = next(iter(set(range(value.ndim)) - set(_AXES_MAP[type(value)]))) |
| 1468 | |
| 1469 | # figure out how to split the value |
| 1470 | remain_key = None |
| 1471 | remain_values: list = [] |
| 1472 | for k, v in d.items(): |
| 1473 | if v is None: |
| 1474 | if remain_key is not None: |
| 1475 | raise ValueError( |