(value)
| 453 | |
| 454 | |
| 455 | def decode_dataframe(value): |
| 456 | if not value: |
| 457 | raise RuntimeError("Value to decode should not be empty") |
| 458 | archive = OutArchive(value) |
| 459 | column_num = archive.get_size() |
| 460 | row_num = archive.get_size() |
| 461 | arrays = {} |
| 462 | |
| 463 | for _ in range(column_num): |
| 464 | col_name = archive.get_string() |
| 465 | dtype = _context_protocol_to_numpy_dtype(archive.get_int()) |
| 466 | if dtype is object: |
| 467 | data_copy = [] |
| 468 | for _ in range(row_num): |
| 469 | data_copy.append(archive.get_string()) |
| 470 | array = np.array(data_copy, dtype=dtype) |
| 471 | else: |
| 472 | array = np.ndarray( |
| 473 | shape=(row_num,), |
| 474 | dtype=dtype, |
| 475 | buffer=archive.get_block(row_num * dtype.itemsize), |
| 476 | ) |
| 477 | arrays[col_name] = array |
| 478 | return pd.DataFrame(arrays) |
| 479 | |
| 480 | |
| 481 | def _unify_str_type(t): # noqa: C901 |
no test coverage detected