I'm reading temperature entries stored in a file. Each entry is generated when the temperature value changes, so it is not stored in regular intervals.
An example of the data could be as follows:
timestamp | temperature
-----------+------------
1477400000 | 31
1477400001 | 31.5
1477400003 | 32
1477400010 | 31.5
1477400200 | 32
1477400201 | 32.5
I would need a fast way to get the temperature at any timestamp, even if it is not in the index. For instance, temperature at 1477400002 would be 31.5, but 1477400002 is not in the index.
For sake of easier reproducibility, the same dataframe may be generated as follows:
df = pd.DataFrame(data={'temperature': [31, 31.5, 32, 31.5, 32, 32.5]},
index=[1477400000, 1477400001, 1477400003, 1477400010, 1477400200, 1477400201])
31.5rather than32?