python - Pandas 中的记录数组是什么?

标签 python numpy pandas dataframe

我找到了以下代码:

df.to_records(index=False)

我试着弄清楚它的作用。我找到了 this页面显示:

Convert DataFrame to record array. Index will be put in the ‘index’ field of the record array if requested

这没有用,因为我不知道record array 是什么意思。我在 to_records 之前和之后打印 df。在屏幕上我看不出有什么不同。

最佳答案

那些是 numpy 记录数组(参见 herehere )。 FWIW,我并没有经常使用它们,因为我发现 DataFrame 对于我需要对数据进行的各种操作要方便得多,我会费心给一个特定的名称。也就是说,很多人都喜欢它们。

它没有改变 df 因为 to_records 不会就地改变 df 从一种类型的对象到另一种类型的对象,它返回目标类型的对象。尝试

ra = df.to_records(index=False)
print ra

看看你做了什么。

关于python - Pandas 中的记录数组是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19712264/

相关文章:

python - 随机森林分类器的决策路径

python - 如何在没有 $0 的情况下获取 shellscript 文件名?

python - 如果总值大于99,如何将十六进制模式设置为lcd?

python - pandas 上的表级格式设置为 html 样式

python - pd.DataFrame 的分组下​​采样和绘图

python - numpy 中的二阶梯度

python - Pandas - 以固定宽度格式的行将数据帧写入文件

python - 将 2D Numpy 灰度值数组转换为 PIL 图像

python - Numpy 选择懒版本

python - pandas:根据条件分组并选择一行