本文介绍了对于pd.interval,Pandas.Series.dtype.kind为None的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

测试代码:

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?

推荐答案

之所以显示为None的原因仅仅是因为IntervalDtype的实现明确设置kind = None .这可能应该更新为'O',尽管此处需要谨慎,因为这会导致意想不到的副作用,例如这将导致is_string_dtype返回True(请参见此处).

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).

这篇关于对于pd.interval,Pandas.Series.dtype.kind为None的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 23:53
查看更多