Skip to content

Commit

Permalink
identify empty columns as string
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadmata committed Feb 25, 2024
1 parent 0269201 commit 0796088
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 100,023 deletions.
8 changes: 7 additions & 1 deletion src/shmessy/types/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ class FloatType(BaseType):
weight = 8

def validate(self, data: ndarray) -> Optional[InferredField]:
at_least_single_not_empty_value: bool = False
for value in data:
try:
self.cast_value(value)
if not at_least_single_not_empty_value and not self.is_empty_value(
value
):
at_least_single_not_empty_value = True
except Exception: # noqa
logger.debug(f"Cannot cast the value '{value}' to {self.name}")
return None
return InferredField(inferred_type=self.name)
if at_least_single_not_empty_value:
return InferredField(inferred_type=self.name)

@property
def prefer_column_casting(self) -> bool:
Expand Down
4 changes: 4 additions & 0 deletions tests/data/data_10.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
col_1,col_2
ohad,
hello,
world
Loading

0 comments on commit 0796088

Please sign in to comment.