fix: use is_string_dtype to check for object/string types
This commit is contained in:
@@ -361,7 +361,7 @@ class FreqaiDataDrawer:
|
||||
label_loc = df.columns.get_loc(label)
|
||||
pred_label_loc = predictions.columns.get_loc(label)
|
||||
df.iloc[-1, label_loc] = predictions.iloc[-1, pred_label_loc]
|
||||
if df[label].dtype == object:
|
||||
if pd.api.types.is_string_dtype(df[label].dtype):
|
||||
continue
|
||||
label_mean_loc = df.columns.get_loc(f"{label}_mean")
|
||||
label_std_loc = df.columns.get_loc(f"{label}_std")
|
||||
|
||||
@@ -435,7 +435,7 @@ class FreqaiDataKitchen:
|
||||
|
||||
for label in predictions.columns:
|
||||
append_dict[label] = predictions[label]
|
||||
if predictions[label].dtype == object:
|
||||
if pd.api.types.is_string_dtype(predictions[label].dtype):
|
||||
continue
|
||||
if "labels_mean" in self.data and label in self.data["labels_mean"]:
|
||||
append_dict[f"{label}_mean"] = self.data["labels_mean"][label]
|
||||
@@ -879,7 +879,7 @@ class FreqaiDataKitchen:
|
||||
|
||||
self.data["labels_mean"], self.data["labels_std"] = {}, {}
|
||||
for label in self.data_dictionary["train_labels"].columns:
|
||||
if self.data_dictionary["train_labels"][label].dtype == object:
|
||||
if pd.api.types.is_string_dtype(self.data_dictionary["train_labels"][label].dtype):
|
||||
continue
|
||||
f = spy.stats.norm.fit(self.data_dictionary["train_labels"][label])
|
||||
self.data["labels_mean"][label], self.data["labels_std"][label] = f[0], f[1]
|
||||
@@ -905,7 +905,7 @@ class FreqaiDataKitchen:
|
||||
self.find_labels(dataframe)
|
||||
|
||||
for key in self.label_list:
|
||||
if dataframe[key].dtype == object:
|
||||
if pd.api.types.is_string_dtype(dataframe[key].dtype):
|
||||
self.unique_classes[key] = dataframe[key].dropna().unique()
|
||||
|
||||
if self.unique_classes:
|
||||
|
||||
@@ -676,7 +676,7 @@ class IFreqaiModel(ABC):
|
||||
self.set_start_dry_live_date(strat_df)
|
||||
|
||||
for label in hist_preds_df.columns:
|
||||
if hist_preds_df[label].dtype == object:
|
||||
if pd.api.types.is_string_dtype(hist_preds_df[label].dtype):
|
||||
continue
|
||||
hist_preds_df[f"{label}_mean"] = 0
|
||||
hist_preds_df[f"{label}_std"] = 0
|
||||
@@ -706,7 +706,7 @@ class IFreqaiModel(ABC):
|
||||
num_candles = self.freqai_info.get("fit_live_predictions_candles", 100)
|
||||
dk.data["labels_mean"], dk.data["labels_std"] = {}, {}
|
||||
for label in full_labels:
|
||||
if self.dd.historic_predictions[dk.pair][label].dtype == object:
|
||||
if pd.api.types.is_string_dtype(self.dd.historic_predictions[dk.pair][label].dtype):
|
||||
continue
|
||||
f = spy.stats.norm.fit(self.dd.historic_predictions[dk.pair][label].tail(num_candles))
|
||||
dk.data["labels_mean"][label], dk.data["labels_std"][label] = f[0], f[1]
|
||||
@@ -896,7 +896,7 @@ class IFreqaiModel(ABC):
|
||||
]
|
||||
self.fit_live_predictions(self.dk, self.dk.pair)
|
||||
for label in label_columns:
|
||||
if dk.full_df[label].dtype == object:
|
||||
if pd.api.types.is_string_dtype(dk.full_df[label].dtype):
|
||||
continue
|
||||
if "labels_mean" in self.dk.data:
|
||||
dk.full_df.at[index, f"{label}_mean"] = self.dk.data["labels_mean"][
|
||||
|
||||
Reference in New Issue
Block a user