Skip to content

Commit 37b2f7c

Browse files
committed
docs: update convert_to docstring and add DatetimeFormatMixin docstring
The SamplerColumnConfig.convert_to docstring incorrectly stated that only "float", "int", or "str" are accepted. Datetime/timedelta samplers accept strftime format strings. Also document the ISO-8601 default.
1 parent 722c33b commit 37b2f7c

File tree

2 files changed

+17
-3
lines changed
  • packages
    • data-designer-config/src/data_designer/config
    • data-designer-engine/src/data_designer/engine/sampling_gen/data_sources

2 files changed

+17
-3
lines changed

packages/data-designer-config/src/data_designer/config/column_configs.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ class SamplerColumnConfig(SingleColumnConfig):
4444
conditional_params: Optional dictionary for conditional parameters. The dict keys
4545
are the conditions that must be met (e.g., "age > 21") for the conditional parameters
4646
to be used. The values of dict are the parameters to use when the condition is met.
47-
convert_to: Optional type conversion to apply after sampling. Must be one of "float", "int", or "str".
48-
Useful for converting numerical samples to strings or other types.
47+
convert_to: Optional type conversion to apply after sampling. For numerical samplers,
48+
must be one of "float", "int", or "str". For datetime and timedelta samplers, accepts
49+
a strftime format string (e.g., ``"%Y-%m-%d"``, ``"%m/%d/%Y %H:%M"``). When omitted,
50+
datetime/timedelta columns default to ISO-8601 format (``YYYY-MM-DDTHH:MM:SS``).
4951
5052
Inherited Attributes:
5153
name (required): Unique name of the column to be generated.
@@ -70,7 +72,12 @@ class SamplerColumnConfig(SingleColumnConfig):
7072
description="Optional dictionary for conditional parameters; keys are conditions, values are params to use when met",
7173
)
7274
convert_to: str | None = Field(
73-
default=None, description="Optional type conversion after sampling: 'float', 'int', or 'str'"
75+
default=None,
76+
description=(
77+
"Optional type conversion after sampling: 'float', 'int', or 'str' for numerical samplers; "
78+
"a strftime format string (e.g., '%Y-%m-%d') for datetime/timedelta samplers. "
79+
"Datetime/timedelta columns default to ISO-8601 (YYYY-MM-DDTHH:MM:SS) when omitted."
80+
),
7481
)
7582
column_type: Literal["sampler"] = "sampler"
7683

packages/data-designer-engine/src/data_designer/engine/sampling_gen/data_sources/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ def validate_data_conversion(convert_to: str | None) -> None:
9090

9191

9292
class DatetimeFormatMixin:
93+
"""Pre/post-processing mixin for datetime and timedelta samplers.
94+
95+
Formatting behavior:
96+
- With ``convert_to``: formats using the given strftime string.
97+
- Without ``convert_to``: returns ISO-8601 strings (``YYYY-MM-DDTHH:MM:SS``).
98+
"""
99+
93100
@staticmethod
94101
def preproc(series: pd.Series, convert_to: str | None) -> pd.Series:
95102
return series

0 commit comments

Comments
 (0)