Skip to content

'Series' object has no attribute 'items' on Python 2.7 #17671

Closed
@mivade

Description

@mivade

Code Sample, a copy-pastable example if possible

Running on the REPL with Python 2.7:

Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import pandas as pd
>>> s = pd.Series([1, 2, 3])
>>> for _, x in s.items():
...     print(x)
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/depalati/miniconda3/envs/py27/lib/python2.7/site-packages/pandas/core/generic.py", line 2966, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'items'

On Python 3.6:

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> s = pd.Series([1, 2, 3])
>>> for _, x in s.items():
...     print(x)
...
1
2
3
>>>

Problem description

The Series.items method is mysteriously absent on Python 2.7, though Series.iteritems works fine on both legacy and modern Python.

Expected Output

Series.items should iterate over (index, value) tuples.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.13.final.0
python-bits: 64
OS: Darwin
OS-release: 16.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None

pandas: 0.20.3
pytest: 3.2.1
pip: 9.0.1
setuptools: 27.2.0
Cython: None
numpy: 1.11.3
scipy: 0.18.1
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.1
feather: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions