Skip to content

Commit ee9be04

Browse files
shwinavnlitvinovkkraus14rgommers
authored
Use a column to store categories, rather than a mapping (#69)
* Use a column to store categories * Make .describe_categoricals["mapping"] a Column * Rename "mapping" -> "categories" in .describe_categorical Co-authored-by: Ashwin Srinath <[email protected]> Co-authored-by: Vasily Litvinov <[email protected]> Co-authored-by: Keith Kraus <[email protected]> Co-authored-by: Ralf Gommers <[email protected]>
1 parent d68dc3d commit ee9be04

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

protocol/dataframe_protocol.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,24 @@ def dtype(self) -> Tuple[enum.IntEnum, int, str, str]:
170170
pass
171171

172172
@property
173-
def describe_categorical(self) -> dict[bool, bool, Optional[dict]]:
173+
def describe_categorical(self) -> dict[bool, bool, Optional[Column]]:
174174
"""
175175
If the dtype is categorical, there are two options:
176176
177177
- There are only values in the data buffer.
178-
- There is a separate dictionary-style encoding for categorical values.
178+
- There is a separate non-categorical Column encoding categorical values.
179179
180180
Raises RuntimeError if the dtype is not categorical
181181
182182
Content of returned dict:
183183
184184
- "is_ordered" : bool, whether the ordering of dictionary indices is
185185
semantically meaningful.
186-
- "is_dictionary" : bool, whether a dictionary-style mapping of
186+
- "is_dictionary" : bool, whether a mapping of
187187
categorical values to other objects exists
188-
- "mapping" : dict, Python-level only (e.g. ``{int: str}``).
189-
None if not a dictionary-style categorical.
188+
- "categories" : Column representing the (implicit) mapping of indices to
189+
category values (e.g. an array of cat1, cat2, ...).
190+
None if not a dictionary-style categorical.
190191
191192
TBD: are there any other in-memory representations that are needed?
192193
"""

0 commit comments

Comments
 (0)