Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

identify empty columns as string #131

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading