Skip to content

iterrows does not preserve dtypes #43245

Closed
@George3d6

Description

@George3d6

Is your feature request related to a problem?

I wish I could use pandas in a way that does not cause bug-hunting for hours to look for a specific spot where nonsensical behavior occurs.

Describe the solution you'd like

The iterrow function (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.iterrows.html) and a few other ways of access do not preserve data types, this is very counterintuitive behavior (unless reading the docs, and making a comment about it for the next guy that maintain the code to see).

Fixing this would involve making sure they return the correct types and potentially adding a breaking_iterrow function that can be used for more efficient type-unaware iteration.

API breaking implications

Would involve changing the behavior of iterrows, might break a few pieces of code that rely upon the arbitrary types this generates (likely without the author realizing)

Describe alternatives you've considered

Leaving comments every time I use pandas iterrows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions