Skip to content Skip to sidebar Skip to footer

Pandas: What Is A NDFrame Object (and What Is 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

Solution 1:

From the horse's mouth:

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

Then what's a DataFrame?

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.

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.

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.


Post a Comment for "Pandas: What Is A NDFrame Object (and What Is A Non-NDFrame Object)"