COMPAT: box int/floats in iter · Issue #13258 · pandas-dev/pandas (original) (raw)

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: