Skip to content

Setting type to category #82

Answered by shaypal5
MagBuchSB1 asked this question in Q&A
Discussion options

You must be logged in to vote

OK. ColumnDtypeEnforcer should actually support this.

For a static column list, this works fine (at least for me), assuming 'a' and 'b' are the labels of you object columns:

dt_enforcer = pdp. ColumnDtypeEnforcer({'a': 'category', 'b': 'category'})
post_df = dt_enforcer(df)

If you want the pipeline stage to convert all object columns to "category", to be determined on runtime, do this:

dt_enforcer = pdp. ColumnDtypeEnforcer({pdp.cq.OfDtypes('object'): 'category'})
post_df = dt_enforcer(df)

This also works fine for me locally. Notice that if you use the same pipeline object several times, and you do not want this column list to have a fit/predict logic (meaning, to be determined once on fi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shaypal5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #72 on January 15, 2022 17:49.