CAVEclient icon indicating copy to clipboard operation
CAVEclient copied to clipboard

Propose adding a `get_l2data_table` method to L2cache

Open bdpedigo opened this issue 6 months ago • 1 comments

(naming of the method completely up for debate)

I almost always do something like the following when I'm grabbing level2 cache data:

def _format_l2_data(level2_data: dict) -> pd.DataFrame:
    level2_data = pd.DataFrame(level2_data).T
    level2_data["x"] = level2_data["rep_coord_nm"].apply(
        lambda x: x[0] if x is not None else None
    )
    level2_data["y"] = level2_data["rep_coord_nm"].apply(
        lambda x: x[1] if x is not None else None
    )
    level2_data["z"] = level2_data["rep_coord_nm"].apply(
        lambda x: x[2] if x is not None else None
    )
    level2_data.index.name = "level2_id"
    level2_data.index = level2_data.index.astype(int)
    return level2_data

I wonder if having a separate method for doing this in CAVEclient, which just calls get_l2data, would be of interest to anyone else? Could also implement it as an alternative return type

bdpedigo avatar Aug 27 '24 22:08 bdpedigo