Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra_data.KeyData.series() support for multi-dimensional data #457

Open
bj-s opened this issue Oct 20, 2023 · 1 comment
Open

Add extra_data.KeyData.series() support for multi-dimensional data #457

bj-s opened this issue Oct 20, 2023 · 1 comment

Comments

@bj-s
Copy link

bj-s commented Oct 20, 2023

extra_data.KeyData supports the pandas.Series output only for one dimensional data. For multi-dimensional data it fails with TypeError: pandas Series are only available for 1D data.

import extra_data as xd

run = xd.open_run(700000, 46).select_trains(slice(0, 50))
pd_series = (
    run[("SQS_DIAG1_XGMD/XGM/DOOCS:output", "data.intensitySa3TD")]
    .series()
)

With MultiIndex, support for multi-dimensional data could be added to produce a pandas.Series like:

import extra_data as xd

run = xd.open_run(700000, 46).select_trains(slice(0, 50))
pd_series = (
    run[("SQS_DIAG1_XGMD/XGM/DOOCS:output", "data.intensitySa3TD")]
    .xarray()
    .to_dataframe()["SQS_DIAG1_XGMD/XGM/DOOCS:output.data.intensitySa3TD"]
)
@takluyver
Copy link
Member

Thanks! It looks like you can even do .xarray().to_series() to get this.

I think it might be best to hold off on a shortcut for this until we have a pulse ID that's meaningful across components, though. The second layer of the MultiIndex you're getting with .to_series() or .to_dataframe() is basically meaningless at the moment, but pandas will still happily line up dim_0 from one series with dim_0 from another and give you garbage results. If we one day have common pulse IDs that we can put in the second index layer, it would make a whole lot more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants