If the dtype is categorical, there are two options: - There are only values in the data buffer. - There is a separate non-categorical Column encoding categorical values. Raises TypeError if the dtype is not categorical Returns the dictionary with
(self)
| 326 | |
| 327 | @property |
| 328 | def describe_categorical(self) -> CategoricalDescription: |
| 329 | """ |
| 330 | If the dtype is categorical, there are two options: |
| 331 | - There are only values in the data buffer. |
| 332 | - There is a separate non-categorical Column encoding categorical |
| 333 | values. |
| 334 | |
| 335 | Raises TypeError if the dtype is not categorical |
| 336 | |
| 337 | Returns the dictionary with description on how to interpret the |
| 338 | data buffer: |
| 339 | - "is_ordered" : bool, whether the ordering of dictionary indices |
| 340 | is semantically meaningful. |
| 341 | - "is_dictionary" : bool, whether a mapping of |
| 342 | categorical values to other objects exists |
| 343 | - "categories" : Column representing the (implicit) mapping of |
| 344 | indices to category values (e.g. an array of |
| 345 | cat1, cat2, ...). None if not a dictionary-style |
| 346 | categorical. |
| 347 | |
| 348 | TBD: are there any other in-memory representations that are needed? |
| 349 | """ |
| 350 | arr = self._col |
| 351 | if not pa.types.is_dictionary(arr.type): |
| 352 | raise TypeError( |
| 353 | "describe_categorical only works on a column with " |
| 354 | "categorical dtype!" |
| 355 | ) |
| 356 | |
| 357 | return { |
| 358 | "is_ordered": self._col.type.ordered, |
| 359 | "is_dictionary": True, |
| 360 | "categories": _PyArrowColumn(arr.dictionary), |
| 361 | } |
| 362 | |
| 363 | @property |
| 364 | def describe_null(self) -> Tuple[ColumnNullType, Any]: |
nothing calls this directly
no test coverage detected