pandas 可能有哪些基本/标量数据类型? [英] What are possible pandas basic / scalar data types?

查看:82
本文介绍了 pandas 可能有哪些基本/标量数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了NumPy的标量类型列表: https://docs.scipy.org/doc/numpy-1.12.0/user/basics.types.html

I found the list of NumPy's scalar types: https://docs.scipy.org/doc/numpy-1.12.0/user/basics.types.html

我知道熊猫在其中添加了时间戳类型.还有其他类型吗?哪里有熊猫标量类型的完整列表?

I know that pandas adds timestamp types to these. Are there any more types? Is there a comprehensive list of pandas scalar types somewhere?

推荐答案

一般而言(和宽松地讲),pandas列只是标记为numpy数组,并且具有可比较的dtype.我唯一知道的例外是熊猫的分类类型.

Generally (and loosely) speaking, pandas columns are just labelled numpy arrays and have comparable dtypes. The only exception I know of is the pandas categorical type.

这是示例dtype列表来自官方文档.不能保证是详尽无遗的,但据我所知它已经非常接近了.

Here's an example dtype listing from the official docs. Not guaranteed to be exhaustive, but to the best of my knowledge it is pretty close.

In [423]: df.dtypes
Out[423]: 
bool1                                   bool
bool2                                   bool
category                            category
dates                         datetime64[ns]
float64                              float64
int64                                  int64
string                                object
uint8                                  uint8
tdeltas                      timedelta64[ns]
uint64                                uint64
other_dates                   datetime64[ns]
tz_aware_dates    datetime64[ns, US/Eastern]
dtype: object

请注意,对象dtype包含字符串,并且基本上只是int,float,bool,category或datetime/timedelta以外的任何内容. dtype对象实际上只是任何通用python类型的持有者,并且可以是列表,字典等.

Note that the object dtype includes strings and is basically just anything except an int, float, bool, category, or datetime/timedelta. An object dtype is really just a holder for any generic python type and could be a list, dictionary, etc.

这篇关于 pandas 可能有哪些基本/标量数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆