【问题标题】:Pandas does uppercase/ lowercase mean anything in dtypes?Pandas 大写/小写在 dtypes 中是否意味着什么?
【发布时间】:2021-01-05 13:41:15
【问题描述】:

Float32 与 float32?

Pandas 中大写和小写 dtype 的用途是什么?

大写似乎更容易出错:TypeError: object cannot be converted to a FloatingDtype。

dtype = {
    'doom_float64': 'Float64'
    , 'radiance_float32': 'Float32'
    , 'temperature_float': 'float'
    , 'moonday_int64': 'Int64'
    , 'month_int32': 'Int32'
    , 'color_uint8': 'UInt8'
    , 'shape_int': 'int'
    , 'weekday_object': 'object'
    , 'hour_object': 'string'
    , 'kingdom_category': 'category'
}
>>> df.dtypes

doom_float64          Float64
radiance_float32      Float32
temperature_float     float64
weekday_object         object
hour_object            string
moonday_int64           Int64
month_int32             Int32
color_uint8             UInt8
shape_int               int64
kingdom_category     category
dtype: object

Pandas v1.2.0

【问题讨论】:

  • 我不确定,但会不会是大写字母用于区分数据类型和 NumPy 的数据类型?

标签: python pandas numpy dtype


【解决方案1】:

是的,例如见here。

pandas 可以使用以下方法表示可能缺少值的整数数据 数组.IntegerArray。这是在内部实现的扩展类型 熊猫。

或字符串别名“Int64”(注意大写“I”,以区分 来自 NumPy 的 'int64' dtype:

大写的类型是 pandas 类型,而非大写的类型是 numpy 类型。

pandas 类型的一个特点是能够支持 nan,这不是非浮点数的标准 IEEE。

【讨论】:

    猜你喜欢
    • 2017-07-11
    • 2022-11-30
    • 2018-07-12
    • 2017-03-02
    • 2013-10-18
    • 2017-05-10
    • 2012-07-14
    • 2011-06-04
    • 2013-07-18
    相关资源
    最近更新 更多