Skip to content

Commit 7242716

Browse files
committed
Column op
1 parent 371d005 commit 7242716

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

databricks/koalas/series.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2023,13 +2023,13 @@ def factorize(self, sort: bool = True, na_sentinel: Optional[int] = -1):
20232023
kvs = list(
20242024
chain(*([(F.lit(unique), F.lit(code)) for unique, code in unique_to_code.items()]))
20252025
)
2026-
sdf = sdf.withColumn(new_scol_name, F.create_map(kvs))
20272026

2028-
null_scol = F.when(scol_for(sdf, scol_name).isNull(), F.lit(na_sentinel_code))
2029-
mapped_scol = scol_for(sdf, new_scol_name).getItem(scol_for(sdf, scol_name))
2030-
sdf = sdf.withColumn(scol_name, null_scol.otherwise(mapped_scol))
2027+
map_scol = F.create_map(kvs)
2028+
null_scol = F.when(self.spark.column.isNull(), F.lit(na_sentinel_code))
2029+
mapped_scol = map_scol.getItem(self.spark.column)
2030+
internal = self._internal.with_new_columns([null_scol.otherwise(mapped_scol)])
20312031

2032-
codes = first_series(DataFrame(self._internal.with_new_sdf(sdf))).astype(np.int64)
2032+
codes = first_series(DataFrame(internal)).astype(np.int64)
20332033

20342034
if na_sentinel is not None:
20352035
uniques = ks.Index([x for x in uniques_list if x is not None])

0 commit comments

Comments
 (0)