Skip to content

Commit

Permalink
Merge pull request #129 from ohadmata/allow-casting-to-string-from-an…
Browse files Browse the repository at this point in the history
…y-source-type

allow casting to string from any source type
  • Loading branch information
ohadmata authored Feb 23, 2024
2 parents 0a77669 + 68ff1e0 commit 89b9345
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/shmessy/types/string.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from typing import Any, Optional, Tuple

import numpy as np
from numpy import ndarray
from pandas import Series

Expand All @@ -28,10 +27,10 @@ def prefer_column_casting(self) -> bool:
return True

def cast_column(self, column: Series, inferred_field: InferredField) -> Series:
raise column.apply(lambda x: str(x))
return column.apply(lambda x: str(x))

def cast_value(self, value: Any, pattern: Optional[Any] = None) -> Optional[Any]:
return str(value)

def ignore_cast_for_types(self) -> Tuple[Any]:
return (np.dtype("O"),)
return tuple()
2 changes: 1 addition & 1 deletion tests/unit/test_boolean_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
df_data={
"test_column": [1, 0, 1, 1, "hello", 1, 1, 0, 1, 0]
},
expected_result=[1, 0, 1, 1, "hello", 1, 1, 0, 1, 0],
expected_result=["1", "0", "1", "1", "hello", "1", "1", "0", "1", "0"],
expected_shmessy_type="String",
expected_numpy_type=np.dtype("object")
)
Expand Down

0 comments on commit 89b9345

Please sign in to comment.