适合时间序列的数据结构

2024-06-12 04:21:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个应用程序,在那里我需要保持一个物体的轨迹。基本上,我想要一个排序字典,其中键是时间,值是位置。此外,我将在现有条目之间进行线性插值。我在Grant Jenks的SortedContainers库中使用过SortedDictionary,它做了很多我想要的功能,但是我想知道是否有更适合的解决方案?提前谢谢你的建议。在


Tags: 功能应用程序字典排序轨迹时间条目解决方案
2条回答

如果时间间隔是可靠的常量,那么可以使用一个列表,当然也可以使用numpy数组。在

否则,您可以在collections模块(std lib)中查看有序字典

    Return an instance of a dict subclass, supporting the usual dict 

methods. An OrderedDict is a dict that remembers the order that keys were first inserted. If a new entry overwrites an existing entry, the original insertion position is left unchanged. Deleting an entry and reinserting it will move it to the end.

如果使用的是pandas,则存在{a2}。在

相关问题 更多 >