Skip to content

Commit 79ea1ba

Browse files
committed
fix: use is_string_dtype to check for object/string types
1 parent f6f0180 commit 79ea1ba

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

freqtrade/freqai/data_drawer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def append_model_predictions(
361361
label_loc = df.columns.get_loc(label)
362362
pred_label_loc = predictions.columns.get_loc(label)
363363
df.iloc[-1, label_loc] = predictions.iloc[-1, pred_label_loc]
364-
if df[label].dtype == object:
364+
if pd.api.types.is_string_dtype(df[label].dtype):
365365
continue
366366
label_mean_loc = df.columns.get_loc(f"{label}_mean")
367367
label_std_loc = df.columns.get_loc(f"{label}_std")

freqtrade/freqai/data_kitchen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def get_predictions_to_append(
435435

436436
for label in predictions.columns:
437437
append_dict[label] = predictions[label]
438-
if predictions[label].dtype == object:
438+
if pd.api.types.is_string_dtype(predictions[label].dtype):
439439
continue
440440
if "labels_mean" in self.data and label in self.data["labels_mean"]:
441441
append_dict[f"{label}_mean"] = self.data["labels_mean"][label]
@@ -879,7 +879,7 @@ def fit_labels(self) -> None:
879879

880880
self.data["labels_mean"], self.data["labels_std"] = {}, {}
881881
for label in self.data_dictionary["train_labels"].columns:
882-
if self.data_dictionary["train_labels"][label].dtype == object:
882+
if pd.api.types.is_string_dtype(self.data_dictionary["train_labels"][label].dtype):
883883
continue
884884
f = spy.stats.norm.fit(self.data_dictionary["train_labels"][label])
885885
self.data["labels_mean"][label], self.data["labels_std"][label] = f[0], f[1]
@@ -905,7 +905,7 @@ def get_unique_classes_from_labels(self, dataframe: DataFrame) -> None:
905905
self.find_labels(dataframe)
906906

907907
for key in self.label_list:
908-
if dataframe[key].dtype == object:
908+
if pd.api.types.is_string_dtype(dataframe[key].dtype):
909909
self.unique_classes[key] = dataframe[key].dropna().unique()
910910

911911
if self.unique_classes:

freqtrade/freqai/freqai_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def set_initial_historic_predictions(
676676
self.set_start_dry_live_date(strat_df)
677677

678678
for label in hist_preds_df.columns:
679-
if hist_preds_df[label].dtype == object:
679+
if pd.api.types.is_string_dtype(hist_preds_df[label].dtype):
680680
continue
681681
hist_preds_df[f"{label}_mean"] = 0
682682
hist_preds_df[f"{label}_std"] = 0
@@ -706,7 +706,7 @@ def fit_live_predictions(self, dk: FreqaiDataKitchen, pair: str) -> None:
706706
num_candles = self.freqai_info.get("fit_live_predictions_candles", 100)
707707
dk.data["labels_mean"], dk.data["labels_std"] = {}, {}
708708
for label in full_labels:
709-
if self.dd.historic_predictions[dk.pair][label].dtype == object:
709+
if pd.api.types.is_string_dtype(self.dd.historic_predictions[dk.pair][label].dtype):
710710
continue
711711
f = spy.stats.norm.fit(self.dd.historic_predictions[dk.pair][label].tail(num_candles))
712712
dk.data["labels_mean"][label], dk.data["labels_std"][label] = f[0], f[1]
@@ -896,7 +896,7 @@ def backtesting_fit_live_predictions(self, dk: FreqaiDataKitchen):
896896
]
897897
self.fit_live_predictions(self.dk, self.dk.pair)
898898
for label in label_columns:
899-
if dk.full_df[label].dtype == object:
899+
if pd.api.types.is_string_dtype(dk.full_df[label].dtype):
900900
continue
901901
if "labels_mean" in self.dk.data:
902902
dk.full_df.at[index, f"{label}_mean"] = self.dk.data["labels_mean"][

0 commit comments

Comments
 (0)