Skip to content

handle ($12.3) type of string in currency conversion #1485

@s-github-2

Description

@s-github-2

Brief Description

enhance currency conversion using 'accounting' to support common excel negative currency strings like ($12.3)

I would like to propose...

Example API

uses existing currency conversion function when handling the 'accounting' format with the following code to handle currency strings - minor edit on existing code makes it more useful

    outcome = (
        df[column_name].astype(str)
        .str.strip()
        .str.replace("$", "", regex=False)
        .str.replace(",", "", regex=False)
        .str.replace(")", "", regex=False)
        .str.replace("(", "-", regex=False)
        .replace({"-": 0.0})
        .astype(float)
    )
    return df.assign(**{column_name: outcome})
# ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions