Skip to content

Commit d2e08b8

Browse files
committed
correcting the order of elements when overwriting features for python kernel
1 parent 8b0d724 commit d2e08b8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/hsfs/engine/python.py

+12
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,13 @@ def _apply_python_udf(
13481348
axis=1,
13491349
result_type="expand",
13501350
)
1351+
if hopsworks_udf.output_column_names[0] in dataframe.columns:
1352+
# Overwriting features so reordering dataframe to move overwritten column to the end of the dataframe
1353+
cols = dataframe.columns.tolist()
1354+
cols.append(
1355+
cols.pop(cols.index(hopsworks_udf.output_column_names[0]))
1356+
)
1357+
dataframe = dataframe[cols]
13511358
else:
13521359
# Dynamically creating lambda function so that we do not need to loop though to extract features required for the udf.
13531360
# This is done because polars 'map_rows' provides rows as tuples to the udf.
@@ -1411,6 +1418,11 @@ def _apply_pandas_udf(
14111418
]
14121419
)
14131420
)
1421+
if hopsworks_udf.output_column_names[0] in dataframe.columns:
1422+
# Overwriting features so reordering dataframe to move overwritten column to the end of the dataframe
1423+
cols = dataframe.columns.tolist()
1424+
cols.append(cols.pop(cols.index(hopsworks_udf.output_column_names[0])))
1425+
dataframe = dataframe[cols]
14141426
return dataframe
14151427

14161428
@staticmethod

0 commit comments

Comments
 (0)