3 ms·
A 2D array has a different algebra from a Dataframe. (though some operators are analogous, e.g. a transpose = a pivot) A dataframe is basically behaves like a
by wenc 9y ago
A 2D array has a different algebra from a Dataframe. (though some operators are analogous, e.g. a transpose = a pivot)
A dataframe is basically behaves like a database table, with all the attendant operations (aggregation, pivots, filters, etc.) The basic algebra for dataframes is relational algebra plus a few other useful database operations.
The algebra for a 2D array (matrix) is linear algebra.
- WaxProlix 9y agoOkay, but on the surface at least these seem computationally equivalent; so is one of these just a special case of the other?
- wenc 9y agoI think there are similarities, but I don't think one is a special case of the other. At a very high level, they are both collection data structures that share certain properties but that are optimized for very different use cases. There are instances where the difference can be palpable. I work with legacy MATLAB code where database type data are stored in cell arrays. They are tremendously difficult to reason with for data science work because the primitive operations are all based on positional cell coordinates. (on the other hand, arrays are much easier to work with for numerical type algorithms) If you understand the theory of coordinatized data, choosing the right coordinate system can greatly simplify math/data manipulation. A data frame is a type of dataset where the coordinates are simply dimensions in other columns, which makes it amenable to aggregations, pivots, slicing/dicing and such on mixed categorical and numerical data.