MCPcopy Create free account
hub / github.com/alibaba/GraphScope / decode_dataframe

Function decode_dataframe

python/graphscope/framework/utils.py:455–478  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

453
454
455def 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
481def _unify_str_type(t): # noqa: C901

Callers 1

wrap_resultsMethod · 0.90

Calls 7

get_sizeMethod · 0.95
get_stringMethod · 0.95
get_intMethod · 0.95
get_blockMethod · 0.95
OutArchiveClass · 0.90
appendMethod · 0.65

Tested by

no test coverage detected