pandas :什么是NDFrame对象(什么是非NDFrame对象) [英] Pandas: what is a NDFrame object (and what is a non-NDFrame object)

查看:351
本文介绍了 pandas :什么是NDFrame对象(什么是非NDFrame对象)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接两个DataFrame,并收到一个'TypeError: cannot concatenate a non-NDFrame object'错误.我一直在环顾四周,很多人都遇到此错误,大多数时候,他们尝试做的事情不是代码真正的工作((这样的答案可以解决他们特定但不相关的问题)

I am trying to concat two DataFrames and am getting a 'TypeError: cannot concatenate a non-NDFrame object' error. I have been looking around, there are a lot of people getting this error, most of the time when they try to do something other than what their code really does, (so the answers solve their particular but unrelated questions)

我的问题不是要解决我的特定问题,而是要了解错误... 什么是非NDFrame对象?为什么不能将其串联?

My question is not to solve my particular problem, but to understand the error... What is a non-NDFrame object? Why can it not be concatenated?

此外,为什么这是关于NDFrames(这些是什么,在哪里使用它们?所有的DataFrames都是NDFrames?是否有不是DataFrames的NDFrames?)...

Also, why is this about NDFrames (What are those, and where do I use them? Are all DataFrames NDFrames? Are there any NDFrames that are not DataFrames?)...

我会理解它是否显示'TypeError: cannot concatenate a non-DataFrame object'(尽管我不确定它们是否不是DataFrames导致了我的错误)这主要是我的好奇心,我不是在尝试寻找任何特定的错误...

I would understand if it said 'TypeError: cannot concatenate a non-DataFrame object' (though I am not sure if them not being DataFrames was the cause of my error) This is mainly my curiosity questing, I am not trying to hunt any specific bug...

推荐答案

从马口中走:

DataFrame的N维模拟.将多维数据存储在大小可变的,带标签的数据结构中

N-dimensional analogue of DataFrame. Store multi-dimensional in a size-mutable, labeled data structure

那么什么是DataFrame?

类DataFrame(NDFrame): 二维大小可变的,可能异构的表格数据 具有标记轴(行和列)的结构.算术运算 在行和列标签上对齐.可以像字典一样 系列对象的容器.

class DataFrame(NDFrame): Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. Can be thought of as a dict-like container for Series objects.

如您所见,DataFrame是NDFrame的子类(即特殊情况).通常,在Pandas程序中,经常使用DataFrame,而很少使用NDFrame.实际上,尽管Pandas的一半名称是Panel,但Pandas的1D系列,2D的DataFrame和大多数人都已经结束了,即使Panel也是

As you can see, a DataFrame is a subclass (i.e. special case) of NDFrame. In Pandas programs generally, DataFrame is used a lot and NDFrame is used rarely. In fact, Pandas has Series for 1D, DataFrame for 2D, and for most people that's the end, even though half of Pandas' name is for Panel which Pandas also has, but most people do not use.

在Pandas中甚至有一个4D东西,但实际上没有人使用它(这是互联网,现在有人会说他们这样做了!).为了获得比2或3个更高的维度,有些人将精力转向了 xarray .如果您的雄心壮志无法包含在2D中,那就可能就是这样.

There is/was even a 4D thing in Pandas, but truly no one uses it (this being the internet, someone will now appear to say they do!). For higher dimensions than two or maybe three, some people have shifted their efforts to xarray. That's probably where it's at if your ambitions cannot be contained in 2D.

这篇关于 pandas :什么是NDFrame对象(什么是非NDFrame对象)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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