pandas.Series.opti.to_indexset#
- Series.opti.to_indexset()[source]#
Cast a Series into an IndexSet1D.
Note: The opti-extensions package has to be imported first to use this method with pandas.
- Returns:
- IndexSet1D
A Series will be cast into an IndexSet1D consisting of its values. The Series name will be set as the IndexSet1D.name attribute (as str).
- Raises:
- ValueError
If the Series is empty.
- TypeError
If the Series has non-scalar value(s) (any iterable except string).
- ValueError
If the Series has duplicate values.
See also
pandas.DataFrame.opti.to_indexsetCast a DataFrame into an IndexSet1D/IndexSetND.
pandas.Index.opti.to_indexsetCast an Index into an IndexSet1D/IndexSetND.
Examples
>>> import pandas as pd >>> import opti_extensions # required to access this method
Casting a Series into an IndexSet1D:
>>> cities = pd.Series(['Delhi', 'Seattle', 'Tokyo'], name='CITY') >>> cities 0 Delhi 1 Seattle 2 Tokyo Name: CITY, dtype: ...
>>> cities.opti.to_indexset() IndexSet1D: (CITY) ['Delhi', 'Seattle', 'Tokyo']