Pandas.Series.dtype.kind is None for pd.interval
Asked Answered
H

1

1

Test code:

s = pd.Series(pd.array([pd.Interval(0,1.2), pd.Interval(5,123)]))
s.dtype
s.dtype.kind is None

>>> interval[float64]
>>> True

Is it some bug or made intentionally? If latter - for what reason?

Heroic answered 30/5, 2019 at 20:5 Comment(2)
But there are others 'pandas-only' specific dtypes - period, category as example. But for them .dtype.kind returns O - object.Heroic
It should be noted that period and category are currently implemented via the extension array interface (same with interval and datetimetz). It's the custom dtype object that determines kind, and the custom dtypes themselves have been around since before the extension array interface.Bitolj
B
1

The reason this is appearing as None is simply because the implementation of IntervalDtype explicitly sets kind = None. This should probably be updated to 'O', though some care is needed here as it will result in unintended side effects, e.g. this would cause is_string_dtype to return True (see here).

Bitolj answered 31/5, 2019 at 20:19 Comment(1)
I think it also should be mention why is_string_dtype checking would become problem.Heroic

© 2022 - 2024 — McMap. All rights reserved.