简体   繁体   English

使用熊猫表示2D数据序列-使用哪种结构?

[英]Using Pandas to represent 2D data series - what structure to use?

I am working with analysis of foot pressure, where each reading is a 52x44 matrix, and a full capture is a time series of these 2D readings. 我正在分析脚的压力,其中每个读数是一个52x44的矩阵,而完整的捕获是这些2D读数的时间序列。

This can easily be represented by a Numpy array of shape (52x44xN), with N depending on the sampling rate and duration of capture. 可以用形状为Numpy的形状(52x44xN)数组轻松表示,N取决于采样率和捕获时间。 With Numpy I already can perform all the operations I need (mostly slicing and simple descriptive statistics). 使用Numpy,我已经可以执行我需要的所有操作(主要是切片和简单的描述性统计)。

I am interested in exploring Pandas capabilities for that, but I wonder what would be suitable column names and structure. 我对探索Pandas的功能感兴趣,但是我想知道哪种列名和结构合适。

With the Numpy 3D array, I have the indices I, J and N. If I use N as the index for a Pandas DataFrame, what would I use as data columns? 使用Numpy 3D数组时,我具有索引I,J和N。如果我将N用作Pandas DataFrame的索引,我将使用什么作为数据列? I would find weird to use I, J and V (value) as columns, because that would create explicit (and redundant) index values, actually using a (3 x (52*44*N)) shaped matrix. 我会发现使用I,J和V(值)作为列很奇怪,因为这实际上会使用(3 x(52 * 44 * N))形状的矩阵来创建显式(和冗余)索引值。

Now if I put an array as the column value, the 3D slicing ("box" selection) would be problematic, wouldn't it? 现在,如果我将数组作为列值,则3D切片(“ box”选择)会出现问题,不是吗?

(EDIT) I've seen something about MultiIndex, but I am not sure as how to use it. (编辑)我已经了解了有关MultiIndex的一些知识,但是我不确定如何使用它。

What do you suggest? 你有什么建议?

Perhaps try using a Pandas Panel for 3-dimensional data. 也许尝试对3维数据使用Pandas Panel

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Panel.html http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Panel.html

For other people's reference, you can find information about 1D ( Series ), 2D ( Dataframe ), and 3D ( Panel ) Pandas structures here: 供其他人参考,您可以在此处找到有关1D( Series ),2D(数据Dataframe )和3D( Panel )Pandas结构的信息:

http://pandas.pydata.org/pandas-docs/stable/dsintro.html http://pandas.pydata.org/pandas-docs/stable/dsintro.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM