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
A DataFrameMapper can be initialized and fit with an empty transformer list without errors. But then an error is thrown when transformation is attempted.
I would expect (and would find it convenient) that a null mapper would be acceptable, and would transform any X to a np.empty((np.size(X, 0), 0)) or to None. Otherwise this ends up being a fairly annoying special case in application logic.
Alternately, if the desired behavior is to throw an error in this situation, it seems that the error is "destined" as soon as the DataFrameMapper is initialized with empty transformer list. So might as well throw the error right away.
In [1]: import pandas as pd
...: from sklearn_pandas import DataFrameMapper
...:
...:
In [2]: X_df = pd.util.testing.makeDataFrame()
...: mapper = DataFrameMapper([], input_df=True)
...:
...:
In [3]: mapper.fit(X_df)
Out[3]:
DataFrameMapper(default=False, df_out=False, features=[], input_df=True,
sparse=False)
In [4]: mapper.transform(X_df)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-0de258be511f> in <module>()
----> 1 mapper.transform(X_df)
/usr/local/anaconda3/lib/python3.7/site-packages/sklearn_pandas/dataframe_mapper.py in transform(self, X)
326 stacked = stacked.toarray()
327 else:
--> 328 stacked = np.hstack(extracted)
329
330 if self.df_out:
/usr/local/anaconda3/lib/python3.7/site-packages/numpy/core/shape_base.py in hstack(tup)
286 return _nx.concatenate(arrs, 0)
287 else:
--> 288 return _nx.concatenate(arrs, 1)
289
290
ValueError: need at least one array to concatenate
The text was updated successfully, but these errors were encountered:
A
DataFrameMapper
can be initialized and fit with an empty transformer list without errors. But then an error is thrown when transformation is attempted.np.empty((np.size(X, 0), 0))
or toNone
. Otherwise this ends up being a fairly annoying special case in application logic.DataFrameMapper
is initialized with empty transformer list. So might as well throw the error right away.The text was updated successfully, but these errors were encountered: