Skip to content

pd.DataFrame.astype should allow dict as argument #12801

Closed
@maxnoe

Description

@maxnoe

Currently pd.DataFrame.astype only allows for one type.

I would like it to support a dict mapping column names to dtypes.
Like for example the dtype argument of pd.read_json.

df = pd.DataFrame({'a': [1, 2, 3], 'b': [1, 2, 3]})
df = df.astype({'a': 'int16', 'b': 'float32'})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsDuplicate ReportDuplicate issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions