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
When the CategoricalTransformer is used with data that contains only numerical data only NaN values, it crashes with a KeyError when trying to transform the NaNs.
What I Did
In [1]: importnumpyasnpIn [2]: importpandasaspdIn [3]: data=pd.Series([1, 2, np.nan])
In [4]: fromrdt.transformersimportCategoricalTransformerIn [5]: ct=CategoricalTransformer()
In [6]: ct.fit_transform(data)
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
<ipython-input-6-9f958bc8253f>in<module>---->1ct.fit_transform(data)
~/Projects/MIT/RDT/rdt/transformers/base.pyinfit_transform(self, data)
44""" 45 self.fit(data)---> 46 return self.transform(data) 47 48 def reverse_transform(self, data):~/Projects/MIT/RDT/rdt/transformers/categorical.py in transform(self, data) 172 data = data.map(MAPS[id(self)]) 173 --> 174 return data.fillna(np.nan).apply(self._get_value).to_numpy() 175 176 def _normalize(self, data):~/.virtualenvs/RDT/lib/python3.8/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds) 4210 else: 4211 values = self.astype(object)._values-> 4212 mapped = lib.map_infer(values, f, convert=convert_dtype) 4213 4214 if len(mapped) and isinstance(mapped[0], Series):pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()~/Projects/MIT/RDT/rdt/transformers/categorical.py in _get_value(self, category) 145 def _get_value(self, category): 146 """Getthevaluethatrepresentsthiscategory."""
-->147mean, std=self.intervals[category][2:]
148ifself.fuzzy:
149returnnorm.rvs(mean, std)
KeyError: nan
The text was updated successfully, but these errors were encountered:
Description
When the
CategoricalTransformer
is used with data that contains only numerical data onlyNaN
values, it crashes with aKeyError
when trying to transform theNaNs
.What I Did
The text was updated successfully, but these errors were encountered: