You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Computing unique values in an empty catalog result in an error. We should add a check for an empty dataframe to ensure we return an empty data frame early.
What I Did
In [4]: importintakeIn [5]: cat=intake.open_esm_datastore("./tests/sample-collections/catalog-dict-records.json")
In [6]: cat_sub=cat.search(variable='foo')
/Users/abanihi/devel/intake/intake-esm/intake_esm/_types.py:303: UserWarning: Query: {'variable': ['foo']} returnedzeroresults.
results=search(self.df, _query, self.columns_with_iterables)
In [7]: cat_subOut[7]: <aws-cesm1-lecatalogwith0dataset(s) from0asset(s)>In [8]: cat_sub.esmcat.unique()
Traceback:
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
<ipython-input-8-37a1bfa1a437>in<module>---->1cat_sub.esmcat.unique()
~/devel/intake/intake-esm/intake_esm/_types.pyinunique(self)
276277defunique(self) ->pd.Series:
-->278returnpd.Series(self._unique())
279280defnunique(self) ->pd.Series:
~/devel/intake/intake-esm/intake_esm/_types.pyin_unique(self)
273returnlist(tlz.unique(values))
274-->275returnself.df[self.df.columns].apply(_find_unique, result_type='reduce').to_dict()
276277defunique(self) ->pd.Series:
~/.mambaforge/envs/intake-esm-dev/lib/python3.9/site-packages/pandas/core/frame.pyinapply(self, func, axis, raw, result_type, args, **kwargs)
8739kwargs=kwargs,
8740 )
->8741returnop.apply()
87428743defapplymap(
~/.mambaforge/envs/intake-esm-dev/lib/python3.9/site-packages/pandas/core/apply.pyinapply(self)
680# one axis empty681elifnotall(self.obj.shape):
-->682returnself.apply_empty_result()
683684# raw~/.mambaforge/envs/intake-esm-dev/lib/python3.9/site-packages/pandas/core/apply.pyinapply_empty_result(self)
750r=np.nan751-->752returnself.obj._constructor_sliced(r, index=self.agg_axis)
753else:
754returnself.obj.copy()
~/.mambaforge/envs/intake-esm-dev/lib/python3.9/site-packages/pandas/core/series.pyin__init__(self, data, index, dtype, name, copy, fastpath)
428index=ibase.default_index(len(data))
429elifis_list_like(data):
-->430com.require_length_match(data, index)
431432# create/copy the manager~/.mambaforge/envs/intake-esm-dev/lib/python3.9/site-packages/pandas/core/common.pyinrequire_length_match(data, index)
529 """
530 if len(data) != len(index):
--> 531 raise ValueError(
532 "Length of values "
533 f"({len(data)}) "
ValueError: Length of values (0) does not match length of index (5)
Description
Computing unique values in an empty catalog result in an error. We should add a check for an empty dataframe to ensure we return an empty data frame early.
What I Did
Traceback:
Relevant lines:
intake-esm/intake_esm/_types.py
Line 275 in ad175fa
The text was updated successfully, but these errors were encountered: