Umberto Fontanazza
Umberto Fontanazza

Reputation: 571

What is the difference betweend pandas.Series.items() and pandas.Series.iteritems()?

As you can see the documentation pages for Series.items() and Series.iteritems() are identical. Is it a mistake? Is one method outdated but kept for backward compatibility?

Most importantly, which one should I use?

Upvotes: 1

Views: 130

Answers (1)

grbeazley
grbeazley

Reputation: 198

Series.iteritems() just calls Series.items() under the hood, see source code below:

def iteritems(self) -> Iterable[tuple[Hashable, Any]]:
    return self.items()

Pandas Source

As a result, you should be fine to use either, although it appears Series.items() is preferred.

Upvotes: 1

Related Questions