简体   繁体   English

pandas 对象(索引、ndarray 等)和数据类型(例如 bool、int、float)之间的区别?

[英]Difference between pandas objects (index, ndarray, etc) and datatypes (e.g. bool, int, float)?

I'm learning pandas and have a pretty basic question.我正在学习熊猫并且有一个非常基本的问题。 I get that pandas introduces a lot of different new objects based on numpy arrays (like index and numpy array), but how are these 'objects' that exist in pandas different from pandas datatypes I'm learning like np.bool, int, float, datetime64?我知道 Pandas 引入了许多基于 numpy 数组(如索引和 numpy 数组)的不同新对象,但是 Pandas 中存在的这些“对象”与我正在学习的 Pandas 数据类型有何不同,例如 np.bool、int、float ,datetime64?

If objects like pandas index's are lego blocks that allow us to do things in pandas, what are these datatypes considered?如果像熊猫索引这样的对象是允许我们在熊猫中做事的乐高积木,那么这些数据类型是什么? are datatypes also pandas objects?数据类型也是熊猫对象吗?

Pandas objects DataFrame , Index and Series provide the high level data structure. Pandas 对象DataFrameIndexSeries提供高级数据结构。

DataFrame is a 2-dimensional labeled data structure with columns of potentially different types. DataFrame是一种二维标记数据结构,具有可能不同类型的列。 You can think of it like a spreadsheet or SQL table, or a dictionary of Series objects.您可以将其视为电子表格或 SQL 表,或Series对象的字典。

Index encapsulates the row and column labels. Index封装了行和列标签。

Series encapsulates a one-dimensional numpy.ndarray containing the column data, row labels and the column label. Series封装了一个一维的numpy.ndarray其中包含列数据、行标签和列标签。

See Pandas DataFrame data structure for details.有关详细信息,请参阅Pandas DataFrame 数据结构


Each column data is a numpy.ndarray object of a specific numpy data type like bool ( numpy.bool_ ), int ( numpy.int32 , numpy.int64 , etc.), float ( numpy.float32 , numpy.float64 , etc.) and others.每列数据都是特定numpy 数据类型numpy.ndarray对象,如 bool ( numpy.bool_ )、int ( numpy.int32numpy.int64等)、 float ( numpy.float32numpy.float64等)和别的。 NumPy supports a much greater variety of numerical types than Python. NumPy 支持的数值类型比 Python 多得多。

See Data types in Python, Numpy and Pandas for details.有关详细信息请参阅Python、Numpy 和 Pandas 中的数据类型

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在独立运行的 python 脚本之间共享 python 对象(例如 Pandas Dataframe) - Sharing python objects (e.g. Pandas Dataframe) between independently running python scripts 列表接受可迭代对象作为输入。 但是,当输入为int或float时,例如list(1),则不接受此输入。 为什么? - Lists accept iterable objects as inputs. However, when the input is an int or float, e.g. list(1), this is not accepted. Why? 如何将功能“附加”到 Python 中的对象,例如 Pandas DataFrame? - How to "attach" functionality to objects in Python e.g. to pandas DataFrame? 数字后面的包含点的数组(例如[1. 2.]与没有点的数组(例如[1 2])和有什么区别? - What is the difference between and array containing dot after the number e.g. [ 1. 2. ] and an array without dot e.g. [ 1 2 ]? 如何测试pandas.Series是否仅包含某些类型(例如int)? - How to test whether pandas.Series contains only certain type (e.g. int)? 如何区分类实例和普通数据类型int / bool / float / etc - How to distinguish between an instance of a class and normal datatype int/bool/float/etc 是否有 Pandas 解决方案(例如:使用 numba 或 Cython)来使用索引、MultiIndexed DataFrame 进行“转换”/“应用”? - Is there a Pandas solution—e.g.: with numba, or Cython—to `transform`/`apply` with an index, a MultiIndexed DataFrame? 使用pandas web.DataReader从整个索引(例如DJIA)获取数据 - Grabbing data from entire index (e.g., DJIA) using pandas web.DataReader 系统日期和字符串之间的时差,例如从目录名开始? - Time difference between system date and string, e.g. from directory name? 在 pipline 中定义步骤或作为 param_grid 中的步骤之间的区别,例如降维 - The difference between defining a step in pipline or as a step in param_grid, e.g. dimensionality reduction
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM