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

apply map for removing .0 #57

Open
npr99 opened this issue Jun 20, 2024 · 2 comments
Open

apply map for removing .0 #57

npr99 opened this issue Jun 20, 2024 · 2 comments

Comments

@npr99
Copy link
Owner

npr99 commented Jun 20, 2024

/workspaces/intersect-community-data/pyncoda/ncoda_07a_generate_hui.py:170: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.
hui_incore_df_fixed = hui_incore_df.applymap(lambda cell: int(cell) if str(cell).endswith('.0') else cell)

@npr99
Copy link
Owner Author

npr99 commented Jun 20, 2024

chat gpt recommends

                def remove_decimal(cell):
                    return int(cell) if isinstance(cell, float) and cell.is_integer() else cell

                # Apply the function to each column
                hui_incore_df_fixed = hui_incore_df.apply(lambda col: col.map(remove_decimal))

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

No branches or pull requests

1 participant