dtoolkit.geoaccessor.dataframe.is_h3#

dtoolkit.geoaccessor.dataframe.is_h3(df: DataFrame, /) bool[source]#

Validate whether the Series is H3 cell index.

Returns:
bool

True if the Series 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
Index([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