Skip to content
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
13 changes: 11 additions & 2 deletions cdisc_rules_engine/check_operators/dataframe_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,19 @@ def _assert_valid_value_and_cast(self, value):

def _custom_str_conversion(self, x):
if pd.notna(x):
if isinstance(x, int):
if isinstance(x, str):
try:
float_val = float(x)
if float_val.is_integer():
return str(int(float_val)).strip()
else:
return str(float_val).strip()
except (ValueError, TypeError):
return x.strip()
elif isinstance(x, int):
return str(x).strip()
elif isinstance(x, float):
return f"{x:.0f}" if x.is_integer() else str(x).strip() # noqa: E231
return f"{x:.0f}" if x.is_integer() else str(x).strip()
return x

def convert_string_data_to_lower(self, data):
Expand Down
2 changes: 1 addition & 1 deletion resources/schema/Operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Value comparison. Works for both string and number.
Has optional parameter:

- 'value_is_reference' when true, the value parameter specifies a column name whose content determines which column to compare against dynamically.
- 'type_insensitive' when true, both values are converted to strings before comparison to handle type mismatches between string and numeric data.
- 'type_insensitive' when true, both values are converted to strings before comparison to handle type mismatches between string and numeric data. NOTE: all trailing zeroes will be removed in both strings and floats.
- 'round_values' when true, both the target and value will be rounded to the nearest integer

> --OCCUR = N
Expand Down
Loading