Skip to content

add groupby to FileContainer? #166

@mathause

Description

@mathause

We have the following snippet

for scen in scenarios_incl_hist:
    files = fc_all.search(scenario=scen)

    # load all members for a scenario
    for fN, meta in files.items():
        ds = xr.open_dataset(fN)

with groupby we could do the following instead:

for scen, fc_scen in fc.groupby("scen"):

    # load all members for a scenario
    for fN, meta in fc_scen.items():
        ds = xr.open_dataset(fN)

A "working" example using groupby of the underlying pandas DataFrame:

import filefisher

ff = filefisher.FileFinder("", "{scen}.nc", test_paths=["hist.nc", "ssp126", "ssp585.nc"])
fc = ff.find_files()

for scen, df  in fc.df.groupby("scen"):
    
    for fN, meta in df.iterrows():
        print(fN)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions