user888379
user888379

Reputation: 1467

Appropriate data structure for time series

I'm working on an application where I will need to maintain an object's trajectory. Basically, I'd like to have something like a sorted dictionary where the keys are times, and the values are positions. In addition, I'll be doing linear interpolation between existing entries. I've played a little bit with SortedDictionary in Grant Jenks's SortedContainers library, and it does a lot of what I want, but I'm wondering if there are solutions out there that are an even better fit? Thanks in advance for any suggestions.

Upvotes: 4

Views: 3507

Answers (2)

hd1
hd1

Reputation: 34657

If you're using pandas, there is time series support available.

Upvotes: 2

Reblochon Masque
Reblochon Masque

Reputation: 36662

If your time interval is reliably constant, a list or of course a numpy array can be used.

Otherwise, you could look into ordered dictionaries in the collections module (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.

Upvotes: 1

Related Questions