Error While Iterating over Dataframe Column's Entries: "Attributeerror: 'Series' Object Has No Attribute 'Iteritems'"

Using pandas version 2, I get an error when calling iteritems.

for event_id, region in column.iteritems():
    pass

The following error message appears:

Traceback (most recent call last):
     File "/home/analyst/anaconda3/envs/outrigger_env/lib/python3.10/site- 
     packages/outrigger/io/gtf.py", line 185, in exon_bedfiles
          for event_id, region in column.iteritems())
AttributeError: 'Series' object has no attribute 'iteritems'

1 Answer

iteritems was removed in 2.0.0 by GH45321.

Removed deprecated Series.iteritems()... use obj.items instead. (from v2.0.0 release notes)

You can use items wherever you used iteritems:

for event_id, region in column.items():
    pass
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest