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

manually changing dataframe for catalog #284

Closed
jgiguereCC opened this issue Mar 8, 2023 · 3 comments
Closed

manually changing dataframe for catalog #284

jgiguereCC opened this issue Mar 8, 2023 · 3 comments

Comments

@jgiguereCC
Copy link

Hi! I'm trying to manually change the dataframe for an esm-datastore and then assign the moditifed dataframe back to a catalog. I've tried using the functionality shown here for intake-esm and the from_df() method showed here, but am getting AttributeError: can't set attribute and AttributeError: from_df from each of these methods respectively. Is there anything I can do to restrict the dataframe, then a new catalogue from that dataframe? I'm still quite new to using xmip/intake-esm, so apologies if this isn't the intended functionality!

import intake
from xmip.postprocessing import merge_variables
import dask
from xmip.drift_removal import unify_time
from xmip.preprocessing import rename_cmip6
url = "https://storage.googleapis.com/cmip6/pangeo-cmip6.json"
col = intake.open_esm_datastore(url)
scenarios = ["ssp370", "piControl", "historical"]  # set desired scenarios
var_name = 'tos'
time_step = ['Oday']
query = dict(experiment_id = scenarios,
             variable_id=var_name,
             table_id = time_step,
             member_id = 'r1i1p1f1'
            )
cat = col.search(require_all_on="source_id", **query)
correct_order = list(cat.df.columns)
new_df = cat.df.groupby(['source_id','experiment_id']).first().reset_index()[correct_order]
cat.df= new_df

Yields the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 19
     17 correct_order = list(cat.df.columns)
     18 new_df = cat.df.groupby(['source_id','experiment_id']).first().reset_index()[correct_order]
---> 19 cat.df= new_df

AttributeError: can't set attribute

Thanks!

@jbusecke
Copy link
Owner

jbusecke commented Mar 9, 2023

I think this is a question specific to intake-esm. Would you mind raising the issue over there? Feel free to tag me there, but I think folks over there will be more knowledgable on this.

@jgiguereCC
Copy link
Author

Thanks, will do!

@jbusecke
Copy link
Owner

I saw that there was a solution posted in intake/intake-esm#579. I will close this if that is ok with you?

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