Skip to content

Commit

Permalink
[python] Extend #3354 to categoricals of arbitrary value type
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Dec 9, 2024
1 parent cbfa704 commit d4ecb17
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions apis/python/src/tiledbsoma/io/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,8 @@ def to_tiledb_supported_array_type(name: str, x: _MT) -> _MT:
# issues in subsequent processing.
if isinstance(x, pd.Series) and isinstance(x.dtype, pd.CategoricalDtype):
# Heuristic number
if (
pandas.api.types.is_string_dtype(x)
and len(x.cat.categories) > STRING_DECAT_THRESHOLD
):
return x.astype(str)
if len(x.cat.categories) > STRING_DECAT_THRESHOLD:
return x.astype(x.cat.categories.dtype)

return x

Expand Down

0 comments on commit d4ecb17

Please sign in to comment.