dtoolkit.geoaccessor.index.is_h3#

dtoolkit.geoaccessor.index.is_h3(index: Index, /) bool[source]#

Validate whether the Index is H3 cell index.

Returns
bool

True if the Index is H3 cell index else False.

Raises
ModuleNotFoundError

If don’t have module named ‘h3’.

TypeError

If the Index dtype is not string or int64.

Examples

>>> import dtoolkit.geoaccessor
>>> import pandas as pd

String type H3 cell index.

>>> index = pd.Index(['88143541bdfffff', '886528b2a3fffff'])
>>> index
Index(['88143541bdfffff', '886528b2a3fffff'], dtype='object')
>>> index.is_h3()
True
>>> s = pd.Series(['a', 'b'], index=['88143541bdfffff', '886528b2a3fffff'])
>>> s
88143541bdfffff    a
886528b2a3fffff    b
dtype: object
>>> s.is_h3()
True
>>> df = pd.DataFrame(
...     {'label': ['a', 'b']},
...     index=['88143541bdfffff', '886528b2a3fffff'],
... )
>>> df
                label
88143541bdfffff     a
886528b2a3fffff     b
>>> df.is_h3()
True

Int type H3 cell index.

>>> index = pd.Index([612845052823076863, 614269156845420543])
>>> index
Int64Index([612845052823076863, 614269156845420543], dtype='int64')
>>> index.is_h3()
True
>>> s = pd.Series(['a', 'b'], index=[612845052823076863, 614269156845420543])
>>> s
612845052823076863    a
614269156845420543    b
dtype: object
>>> s.is_h3()
True
>>> df = pd.DataFrame(
...     {'label': ['a', 'b']},
...     index=[612845052823076863, 614269156845420543],
... )
>>> df
                    label
612845052823076863     a
614269156845420543     b
>>> df.is_h3()
True