Pytorch Temporal Fusion Transformer - TimeSeriesDataSet TypeError: '<' not supported between instances of 'int' and 'str'
I'm following Temporal-Fusion-Transformer (TFT) tutorial in the PytorchForecasting (https://pytorch-forecasting.readthedocs.io/en/stable/tutorials/stallion.html#Demand-forecasting-with-the-Temporal-Fusion-Transformer) to train TFT model with custom dataset to predict &quot;booking&quot; value based on several static/time-varying features for each Sold TO Party in each Region and Sub-Region.
When converting the dataframe into a PyTorch Forecasting TimeSeriesDataSet, I encountered the error: &quot;TypeError: '&lt;' not supported between instances of 'int' and 'str'.&quot; Does anyone know what's potential issue for this error?
The code is as follows:
max_prediction_length = 2
max_encoder_length = 8
training_cutoff = ctmdata[&quot;time_idx&quot;].max() - max_prediction_length
target_value = &quot;Booking&quot;
key_idx = [&quot;Region&quot;,&quot;Sub-Region&quot;,&quot;Sold TO Party Code&quot;]

training = TimeSeriesDataSet(
    ctmdata[lambda x: x.time_idx &lt;= training_cutoff],
    time_idx=&quot;time_idx&quot;,
    target=target_value,
    group_ids=key_idx,
    min_encoder_length=max_encoder_length // 2,  # keep encoder length long (as it is in the validation set)
    max_encoder_length=max_encoder_length,
    min_prediction_length=1,
    max_prediction_length=max_prediction_length,
    static_categoricals=[&quot;Region&quot;,&quot;Sub-Region&quot;,&quot;Sold TO Party Code&quot;,&quot;Customer Type&quot;,&quot;Customer Segment L1&quot;,&quot;Customer Segment L2&quot;],
    static_reals=[],
    time_varying_known_categoricals=[&quot;Supply Chain Customer&quot;,&quot;Quarter&quot;],
    variable_groups={},  # group of categorical variables can be treated as one variable
    time_varying_known_reals=[&quot;time_idx&quot;],
    time_varying_unknown_categoricals=[&quot;DW Customer&quot;], 
    time_varying_unknown_reals=[
        &quot;Booking&quot;,&quot;yeojohnson_Booking&quot;,&quot;avg_booking_bySubRegion&quot;,&quot;avg_booking_byCTMSegL1&quot;,
        &quot;Billing&quot;,&quot;yeojohnson_Billing&quot;,&quot;avg_billing_bySubRegion&quot;,&quot;avg_billing_byCTMSegL1&quot;,
        &quot;MGP&quot;,&quot;MGP%&quot;,&quot;BB Ratio&quot;
    ],
    target_normalizer=GroupNormalizer(
        groups=key_idx, transformation=&quot;softplus&quot;
    )  # use softplus and normalize by group
)

The error message shows:
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-119-9cc2c7eb9aa5&gt; in &lt;module&gt;()
     38     ],
     39     target_normalizer=GroupNormalizer(
---&gt; 40         groups=key_idx, transformation=&quot;softplus&quot;
     41     )  # use softplus and normalize by group
     42 )

4 frames
/usr/local/lib/python3.7/dist-packages/pytorch_forecasting/data/timeseries.py in __init__(self, data, time_idx, target, group_ids, weight, max_encoder_length, min_encoder_length, min_prediction_idx, min_prediction_length, max_prediction_length, static_categoricals, static_reals, time_varying_known_categoricals, time_varying_known_reals, time_varying_unknown_categoricals, time_varying_unknown_reals, variable_groups, constant_fill_strategy, allow_missing_timesteps, lags, add_relative_time_idx, add_target_scales, add_encoder_length, target_normalizer, categorical_encoders, scalers, randomize_length, predict_mode)
    432 
    433         # preprocess data
--&gt; 434         data = self._preprocess_data(data)
    435         for target in self.target_names:
    436             assert target not in self.scalers, &quot;Target normalizer is separate and not in scalers.&quot;

/usr/local/lib/python3.7/dist-packages/pytorch_forecasting/data/timeseries.py in _preprocess_data(self, data)
    651             # use existing encoder - but a copy of it not too loose current encodings
    652             encoder = deepcopy(self.categorical_encoders.get(group_name, NaNLabelEncoder()))
--&gt; 653             self.categorical_encoders[group_name] = encoder.fit(data[name].to_numpy().reshape(-1), overwrite=False)
    654             data[group_name] = self.transform_values(name, data[name], inverse=False, group_id=True)
    655 

/usr/local/lib/python3.7/dist-packages/pytorch_forecasting/data/encoders.py in fit(self, y, overwrite)
     88 
     89         idx += offset
---&gt; 90         for val in np.unique(y):
     91             if val not in self.classes_:
     92                 self.classes_[val] = idx

&lt;__array_function__ internals&gt; in unique(*args, **kwargs)

/usr/local/lib/python3.7/dist-packages/numpy/lib/arraysetops.py in unique(ar, return_index, return_inverse, return_counts, axis)
    270     ar = np.asanyarray(ar)
    271     if axis is None:
--&gt; 272         ret = _unique1d(ar, return_index, return_inverse, return_counts)
    273         return _unpack_tuple(ret)
    274 

/usr/local/lib/python3.7/dist-packages/numpy/lib/arraysetops.py in _unique1d(ar, return_index, return_inverse, return_counts)
    331         aux = ar[perm]
    332     else:
--&gt; 333         ar.sort()
    334         aux = ar
    335     mask = np.empty(aux.shape, dtype=np.bool_)

TypeError: '&lt;' not supported between instances of 'int' and 'str'

Thanks for help!

You can check the values in the static_categoricals=[&quot;Region&quot;,&quot;Sub-Region&quot;,&quot;Sold TO Party Code&quot;,&quot;Customer Type&quot;,&quot;Customer Segment L1&quot;,&quot;Customer Segment L2&quot;], maybe you are passing a value that have a str and this is trying to be compare with a int
