DateRangeConverter
Date the rows of a dataset that only holds a series of values.
A forecasting task reads its time index from a Date column, so a file
with the values alone cannot be forecast. This converter adds that
column: the first row gets the start date and every following row the
next period of the frequency, with pandas.date_range.
It dates the rows in the order they come in the file, and nothing can check that this is their order in time, or that no period is missing. That is the user's to know, and the description says so. Nothing is sorted or filled: the rows stay as they are, and the dataset gains one column.
The frequency is one of FREQUENCIES, each of which sits on the grid a
forecast checks (validate_grid) once written in the stored format and
read back. A start off the frequency's anchor and fewer rows than a
frequency can be inferred from are refused, never corrected.
It only runs in a notebook (NOTEBOOK_ONLY): a session transforms each
split on its own, and each would start again at the start date. It reads
no column (input_cardinality exact 0). A notebook hands an empty
scope over as every column, so transform returns them unchanged next
to the new one, and numbers the new name itself: the merge only numbers
names outside the scope.
Parameters
- start_date : string, default=
2024-01-01 - The date of the first row of the file, as YYYY-MM-DD or YYYY-MM-DD HH:SS. It has to fall on the frequency's grid: the last day of the month for the monthly one at the end of the month, a Monday for the weekly one.
- frequency : string, default=
D - The step between two rows.
- column_name : string, default=
date - The name of the new date column. If the dataset already has a column with that name, the new one is numbered: date_1.
Methods
fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DateRangeConverter'
DateRangeConverterCheck the start date, the frequency and the name.
Parameters
- x : DashAIDataset
- Ignored: the converter reads no column.
- y : DashAIDataset, optional
- Ignored. Defaults to None.
Returns
- DateRangeConverter
- The fitted converter instance (self).
get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType
DateRangeConverterThe new column's type: a Date stored as text, with its format.
Parameters
- column_name : str, optional
- Ignored: the converter adds one column. Defaults to None.
Returns
- DashAIDataType
Datewith the formattransformchose, or the default one before it ran.
transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'
DateRangeConverterAdd the date column next to the columns of x, unchanged.
Parameters
- x : DashAIDataset
- The rows to date, in file order. Its columns come back as they are.
- y : DashAIDataset, optional
- Ignored. Defaults to None.
Returns
- DashAIDataset
xwith one more column: aDatestored as text in the format the dates need.
build_report(self, data: 'Dict[str, Any]') -> 'Dict[str, Any]'
BaseConverterWrap converter-specific data with the producer converter name.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_metadata(cls) -> 'Dict[str, Any]'
BaseConverterGet metadata for the converter, used by the DashAI frontend.
Parameters
- cls : type
- The converter class (injected automatically by Python for classmethods).
Returns
- Dict[str, Any]
- Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.
get_report(self) -> 'Union[Dict[str, Any], None]'
BaseConverterReturn the converter report produced after execution, if any.
Returns
- Dict[str, Any] or None
- JSON-serializable report dict, or
Nonewhen the converter does not produce one.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
infer_output_columns(self, inputs: 'List[StateItem]') -> 'StructureDelta'
BaseConverterEstimate what this converter does to its scope, without any data.
Parameters
- inputs : list of ColumnItem | BlockItem
- The dataset state items in this converter's scope.
Returns
- StructureDelta
- The scope items that survive (maybe retyped) and the new items.
rows_to_keep(self, x: "'DashAIDataset'") -> 'List[int]'
BaseConverterPositions of the rows of x that survive this converter.
Parameters
- x : DashAIDataset
- The converter's scope columns of one split.
Returns
- list of int
- 0-based positions of the kept rows, in order.
runs_in_session(cls) -> 'bool'
BaseConverterWhether a model session can take this converter as a step.
Returns
- bool
- True when a session can run it.
session_params(cls, params: 'Optional[Dict[str, Any]]') -> 'Dict[str, Any]'
BaseConverterA session step's params, with the session defaults under them.
Parameters
- params : dict or None
- The params the step stores.
Returns
- dict
SESSION_PARAMSupdated withparams: what the step gives wins.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.