-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DataFrame.apply to support additional dtypes. (#2125)
Fix `DataFrame.apply` to support additional dtypes. After this, additional dtypes can be specified in the return type annotation of the UDFs for `DataFrame.apply`. ```py >>> kdf = ks.DataFrame( ... {"a": ["a", "b", "c", "a", "b", "c"], "b": ["b", "a", "c", "c", "b", "a"]} ... ) >>> dtype = pd.CategoricalDtype(categories=["a", "b", "c"]) >>> def categorize(ser) -> ks.Series[dtype]: ... return ser.astype(dtype) ... >>> applied = kdf.apply(categorize) >>> applied a b 0 a b 1 b a 2 c c 3 a c 4 b b 5 c a >>> applied.dtypes a category b category ``` FYI: without the fix: ```py >>> applied a b 0 0 1 1 1 0 2 2 2 3 0 2 4 1 1 5 2 0 >>> applied.dtypes a int64 b int64 dtype: object ```
- Loading branch information
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters