Skip to content

COMPAT: box int/floats in __iter__ #13258

Closed
@jreback

Description

@jreback

xref #13236 as .map was recently clarified to box ints/floats (and all other dtypes) to python/pandas types (rather than numpy scalars). __iter__ should do the same (it already is done for datetimelikes), need to add for int/floats.

Furthermore Series.tolist() also returns python types (#10904)

This will make it more consistent with pandas iteration strategy.

We also already do this for object types

In [12]: type(list(Series([Timestamp('20130101'),Timestamp('20130101',tz='US/Eastern'),1,1.0,'foo']))[2])
Out[12]: int

.tolist()

In [3]: type(Series([1,2,3]).tolist()[2])
Out[3]: int

let's fix for pure types

In [14]: type(list(Series([1,2,3]))[2])
Out[14]: numpy.int64

When solving this issue, also have to look at:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsDtype ConversionsUnexpected or buggy dtype conversions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions