Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Refactor DataFrame Operations to Avoid Chained Assignment and Address FutureWarning in Pandas #637

Copy link
Copy link
Closed
@mattbrth

Description

@mattbrth
Issue body actions

Proposal:
Refactor DataFrame operations to avoid chained assignment and resolve FutureWarning in pandas, ensuring compatibility with the upcoming changes in pandas 3.0.

Current behavior:
Using data_frame[k].replace('', np.nan, inplace=True) triggers a FutureWarning regarding chained assignment, indicating that this approach will not be supported in pandas 3.0.

Desired behavior:
Adopt a refactoring approach that aligns with pandas' best practices and future compatibility, such as using data_frame[k] = data_frame[k].replace('', np.nan) or data_frame.replace({k: ''}, np.nan, inplace=True).

Alternatives considered:

  1. Use data_frame[k] = data_frame[k].replace('', np.nan) for direct column operations.
  2. Use data_frame.replace({k: ''}, np.nan, inplace=True) to apply the replacement across the entire DataFrame.

Use case:
Ensuring that the DataFrame operations are future-proof and compatible with upcoming versions of pandas is essential for the maintainability and stability of the codebase. This change will prevent potential runtime errors or unexpected behaviors resulting from deprecated practices in pandas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.