是否可以将二维数组作为二维数据帧的元素?
我是一名学生,正在使用视频编码器做我的项目。我已经提取了像素值和其他信息(POC、x 位置、y 位置、高度、宽度)并将它们保存在 txt 文件中。 我将使用 h5py 将这些数据转换为 hdf5 文件。但我想知道 pandas 甚至 hdf5 是否支持 pandas 2D 数据帧中的 2D 数组(像素值)。
例如,让 p = [[1,2],[3,4]] 作为我的像素值。我可以让我的数据框像 数据集[0] = [0(POC),0(x),0(y),p(2D 数组像素值)]? 或者甚至可以用 hdf5 格式编写?
I am a student doing my project with video encoder. I have extracted pixel values with other info (POC, x position, y position, height, width) with them in txt files.
I am going to convert these data into hdf5 files with h5py. But I wonder if pandas or even hdf5 support having a 2D-array(the pixel values) in a pandas 2D dataframe.
For example, let p = [[1,2],[3,4]] as my pixel value. May I have my dataframe be like
dataset[0] = [0(POC),0(x),0(y),p(2D array pixel values)]?
Or can it even written in hdf5 format?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,你可以,这里有一个例子:
输出:
如你所见,你可以在 pandas 数据框中拥有列表、列表列表、字典、列表字典、字典列表等。
输出:
输出:
Yes, you can, here goes an example:
Output:
As you can see, you can have lists, lists of lists, dictionaries, dictionaries of lists, lists of dictionaries, etc, inside a pandas dataframe.
Output:
Output:
下面是一个使用 h5py 创建 HDF5 文件并加载一些简单数据作为属性的示例。
您可以使用 HDFView 查看数据。输出:
Here is an example that creactes the HDF5 file with h5py and loads some simple data as attributes.
You can view the data with HDFView. Output: