libb.isiterable

isiterable(obj)[source]

Check if object is iterable (excluding strings).

Parameters:

obj – Object to check.

Returns:

True if iterable and not a string.

Return type:

bool

Example:

>>> isiterable([])
True
>>> isiterable(tuple())
True
>>> isiterable(object())
False
>>> isiterable('foo')
False

Note: DataFrames and arrays are iterable:

>>> import pandas as pd
>>> isiterable(pd.DataFrame([['foo', 1]], columns=['key', 'val']))
True
>>> import numpy as np
>>> isiterable(np.array([1,2,3]))
True