Hierarchical latency graph, bugfixes, renamed types.py to not interfere with other python packages.
This commit is contained in:
parent
5885be5974
commit
0261b8200f
10 changed files with 1022 additions and 170 deletions
|
@ -1,15 +1,25 @@
|
|||
import sys
|
||||
|
||||
import pandas as pd
|
||||
from tqdm.notebook import tqdm
|
||||
|
||||
|
||||
def row_to_type(row, type, has_idx, **type_kwargs):
|
||||
return type(id=row.name, **row, **type_kwargs) if has_idx else type(**row, **type_kwargs)
|
||||
def row_to_type(row, type, **type_kwargs):
|
||||
return type(**row, **type_kwargs)
|
||||
|
||||
|
||||
def df_to_type_list(df, type, **type_kwargs):
|
||||
has_idx = not isinstance(df.index, pd.RangeIndex)
|
||||
return [row_to_type(row, type, has_idx, **type_kwargs) for _, row in df.iterrows()]
|
||||
ret_list = []
|
||||
p = tqdm(desc=" ├─ Processing", total=len(df))
|
||||
for row in df.itertuples(index=has_idx):
|
||||
p.update()
|
||||
row_dict = row._asdict()
|
||||
if has_idx:
|
||||
row_dict["id"] = row.Index
|
||||
del row_dict["Index"]
|
||||
ret_list.append(row_to_type(row_dict, type, **type_kwargs))
|
||||
return ret_list
|
||||
|
||||
|
||||
def by_index(df, index, type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue