Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #37 set copy warning #63

Merged
merged 1 commit into from
Jul 9, 2021
Merged

fix #37 set copy warning #63

merged 1 commit into from
Jul 9, 2021

Conversation

JanBenisek
Copy link
Contributor

Fixes warning A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_index,col_indexer] = value instead

The issue was actually in how Cobra is used, not the code. In the documentation, we do the following:

# fit the pipeline (will automatically be stored to "path" variable)
preprocessor.fit(basetable[basetable["split"]=="train"],
                 continuous_vars=continuous_vars,
                 discrete_vars=discrete_vars,
                 target_column_name=target_column_name)

You notice that first parameter, where we are passing slice of a dataframe. When we further operate on that dataframe (adding features), the warning is triggered, since we are working with a slice.

Solution
Enforce .copy() of the dataframe before we work with it, inside cobra.

Source of the warning: https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas

@JanBenisek JanBenisek added this to the v1.0.2 milestone Jul 8, 2021
@JanBenisek JanBenisek linked an issue Jul 8, 2021 that may be closed by this pull request
Copy link
Contributor

@sandervh14 sandervh14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK!

@sandervh14 sandervh14 merged commit 104d198 into develop Jul 9, 2021
@sandervh14 sandervh14 deleted the fix/issue#37 branch July 9, 2021 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Value is trying to set on a copy
2 participants