return res
def _transform(self, df, verbose):
cols_to_exclude = self._exclude_columns.copy()
if self._exclude_obj_cols:
obj_cols = list((df.dtypes[df.dtypes == object]).index)
obj_cols = [x for x in obj_cols if x not in cols_to_exclude]
cols_to_exclude += obj_cols
self._col_order = list(df.columns)
if cols_to_exclude:
excluded = df[cols_to_exclude]
apply_to = df[
[col for col in df.columns if col not in cols_to_exclude]
]
else:
apply_to = df
try:
res = pd.DataFrame(
data=self._scaler.transform(apply_to),
index=apply_to.index,
columns=apply_to.columns,
)
except Exception:
raise PipelineApplicationError(
"Exception raised when Scale applied to columns {}".format(
apply_to.columns
)
)
if cols_to_exclude:
res = pd.concat([res, excluded], axis=1)
res = res[self._col_order]
return res
class TfidfVectorizeTokenLists(PdPipelineStage):
After Change
)
if len(unscaled_cols) > 0:
unscaled = df[unscaled_cols]
inter_df = pd.concat([inter_df, unscaled], axis=1)
inter_df = inter_df[col_order]
return inter_df
class TfidfVectorizeTokenLists(PdPipelineStage):