TSFileLoader¶
- class torchtime.io.TSFileLoader(filepath: str, nan_replace_value: Union[int, float, str] = 'NaN')[source]¶
File loader that can load time series files in sktimes .ts file format.
- Parameters:
- class State(value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
TSFileLoader’s internal parsing state.
- as_tensor(return_targets: bool = False) Union[Tensor, Tuple[Tensor, List[str]]] [source]¶
Return the loaded data as a 3-dimensional tensor of the form (N, C, S).
- as_dataframe(return_targets: bool = False) DataFrame [source]¶
Return the loaded data as a pandas dataframe.
- Keyword Arguments:
return_targets (bool) – Identifies whether the targets should be included in the returned dataframe. If
effect (True, the targets will be added as an additional column 'targets' to the dataframe. This only has an) –
place. (if there are class labels available in the datafile that was parsed in the first) –
- Returns:
A nested pandas dataframe holding the dimensions as columns and the number examples as rows, where every cell contains a pandas Series containing a univariate time series. If return_targets is set, it will also contain a column ‘targets’ that contains the class labels of every example.
- Return type:
pd.DataFrame
- Parameters:
return_targets (bool) –
- get_classes()[source]¶
Return the classes found in the ‘.ts’ file
- Returns:
List of class names as string.
- Return type:
List[str]
- parse_header(line: str) None [source]¶
Parses a line of a .ts file header and updates the internal state of the loader with the extracted information.
- Parameters:
line (str) – The header line to parse.
- Returns:
None
- Return type:
None
- parse_header_value(value: str, value_type: TsTagValuePattern) Union[bool, str, int, List[str]] [source]¶
Parse a single header value that was extracted by the header line parser and return its value as the appropriate python object.
- Parameters:
value (str) – Extracted header value that should be parsed.
value_type (TsTagValuePattern) – The expected type of the value, which should be applied.
- Returns:
If the value is of type BOOLEAN. value converted to bool str: If the value is of type ANY_CONNECTED_STRING. Returns the stripped value string. List[str]: If the value is of type CLASS_LABEL. Returns a list of space separated string class labels.
- Return type:
- parse_body(line: str) None [source]¶
Parse a line of the @data content of a .ts file if @timeStamps is False.
- Parameters:
line (str) – The @data line to parse.
- Returns:
None
- Return type:
None
- parse_timestamp_tuple(tuple_data: str, line_dim: int) Tuple[Union[str, int], float] [source]¶
Parse a timestamp tuple of the form (<timestamp>,<float>)
- Parameters:
- Returns:
If the timestamp can be interpreted as an integer, return a tuple of the timestamp as int and the value as float. Tuple[str, float]: Else, the timestamp is probably a date, return a tuple of the timestamp as str and the value as float. The timestamp is later converted to an actual DateIndex using pandas.
- Return type:
- parse_body_timestamps(line: str) None [source]¶
Parse a line of the @data content of a .ts file if @timeStamps is True.
- Parameters:
line (str) – The @data line to parse.
- Returns:
None
- Return type:
None