w3resource

Pandas Series: items() function

Lazily iterate over tuples in Pandas

The items() function is used to lazily iterate over (index, value) tuples.

This method returns an iterable tuple (index, value). This is convenient if you want to create a lazy iterator.

Syntax:

Series.items(self)

Returns: iterable
Iterable of tuples containing the (index, value) pairs from a Series.

Example :

Python-Pandas Code:

import numpy as np
import pandas as pd
s = pd.Series(['P', 'Q', 'R'])
for index, value in s.items():
    print("Index : {}, Value : {}".format(index, value))

Output:

Index : 0, Value : P
Index : 1, Value : Q
Index : 2, Value : R

Previous: Access a group of rows and columns in Pandas
Next: Get item and drop from frame



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/series/series-items.php