Error while iterating over dataframe column's entries: "AttributeError: 'Series' object has no attri

May 2024 ยท 1 minute read

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

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobm9qYGWBdn6Onqmrp6JixKm1y55koqyVp661tc2gZKiulad6pa3Tmp2rmZ2aeqS7y66kp6tdmru1vsieqmaZpKm%2Fqq7UrZyeqqKkv26%2FxKugnqs%3D