Woodwork not initialized after to_pandas call with Koalas categorical column
- Ngôn ngữ chính
- Python
- Star
- 155
- Fork
- 24
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
After calling to_pandas on a koalas dataframe with a categorical column that has been initialized by woodwork, we'd expect to receive a pandas dataframe that has woodwork initialized. However, we get a `WoodworkNotInitError`.
#### Code Sample
``` python
import pandas as pd
import woodwork as ww
df = pd.DataFrame({'categorical': pd.Series(["a", "b", "c", "a"], dtype="category")})
ks_df = ks.from_pandas(df)
ks_df.ww.init(name='woodwork')
pd_df = ks_df.ww.to_pandas()
pd_df.ww
```
#### Stack Trace
``` python
---------------------------------------------------------------------------
WoodworkNotInitError Traceback (most recent call last)
~/Documents/woodwork/venv/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj)
700 type_pprinters=self.type_printers,
701 deferred_pprinters=self.deferred_printers)
--> 702 printer.pretty(obj)
703 printer.flush()
704 return stream.getvalue()
~/Documents/woodwork/venv/lib/python3.8/site-packages/IPython/lib/pretty.py in pretty(self, obj)
392 if cls is not object \
393 and callable(cls.__dict__.get('__repr__')):
--> 394 return _repr_pprint(obj, self, cycle)
395
396 return _default_pprint(obj, self, cycle)
~/Documents/woodwork/venv/lib/python3.8/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
698 """A pprint that just redirects to the normal repr function."""
699 # Find newlines and replace them with p.break_()
--> 700 output = repr(obj)
701 lines = output.splitlines()
702 with p.group():
~/Documents/woodwork/woodwork/table_accessor.py in __repr__(self)
217 def __repr__(self):
218 """A string representation of a Woodwork table containing typing information"""
--> 219 return repr(self._get_typing_info())
220
221 def _repr_html_(self):
~/Documents/woodwork/woodwork/table_accessor.py in _get_typing_info(self)
227 """Creates a DataFrame that contains the typing information for a Woodwork table."""
228 if self._schema is None:
--> 229 _raise_init_error()
230 typing_info = self._schema._get_typing_info().copy()
231 typing_info.insert(0, 'Physical Type', pd.Series(self.physical_types))
~/Documents/woodwork/woodwork/table_accessor.py in _raise_init_error()
968
969 def _raise_init_error():
--> 970 raise WoodworkNotInitError("Woodwork not initialized for this DataFrame. Initialize by calling DataFrame.ww.init")
971
972
WoodworkNotInitError: Woodwork not initialized for this DataFrame. Initialize by calling DataFrame.ww.init
---------------------------------------------------------------------------
WoodworkNotInitError Traceback (most recent call last)
~/Documents/woodwork/venv/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj)
343 method = get_real_method(obj, self.print_method)
344 if method is not None:
--> 345 return method()
346 return None
347 else:
~/Documents/woodwork/woodwork/table_accessor.py in _repr_html_(self)
222 """An HTML representation of a Woodwork table for IPython.display in Jupyter Notebooks
223 containing typing information and a preview of the data."""
--> 224 return self._get_typing_info().to_html()
225
226 def _get_typing_info(self):
~/Documents/woodwork/woodwork/table_accessor.py in _get_typing_info(self)
227 """Creates a DataFrame that contains the typing information for a Woodwork table."""
228 if self._schema is None:
--> 229 _raise_init_error()
230 typing_info = self._schema._get_typing_info().copy()
231 typing_info.insert(0, 'Physical Type', pd.Series(self.physical_types))
~/Documents/woodwork/woodwork/table_accessor.py in _raise_init_error()
968
969 def _raise_init_error():
--> 970 raise WoodworkNotInitError("Woodwork not initialized for this DataFrame. Initialize by calling DataFrame.ww.init")
971
972
WoodworkNotInitError: Woodwork not initialized for this DataFrame. Initialize by calling DataFrame.ww.init
```
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.