我找到了以下代码:
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
记录数组(参见 here 和 here )。 FWIW,我并没有经常使用它们,因为我发现 DataFrame
对于我需要对数据进行的各种操作要方便得多,我会费心给一个特定的名称。也就是说,很多人都喜欢它们。
它没有改变 df
因为 to_records
不会就地改变 df
从一种类型的对象到另一种类型的对象,它返回目标类型的对象。尝试
ra = df.to_records(index=False)
print ra
看看你做了什么。
关于python - Pandas 中的记录数组是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19712264/