pandas.Series.dex.to_indexset#
- Series.dex.to_indexset()#
Cast a Series into an IndexSet1D.
Note: The docplex-extensions pacakge 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.dex.to_indexsetCast a DataFrame into an IndexSet1D/IndexSetND.
pandas.Index.dex.to_indexsetCast an Index into an IndexSet1D/IndexSetND.
Examples
>>> import pandas as pd >>> import docplex_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: object
>>> cities.dex.to_indexset() IndexSet1D: (CITY) ['Delhi', 'Seattle', 'Tokyo']