Skip to content
Advertisement

Transformation of time series data arranged as value per column into Pandas 2D Dataframe

I have data where 13000 high frequency time-series data points are mapped as one column per point assosiated with one timestamp, when the data was measured. I read this data from an influxDB and get a Pandas.DataFrame structured as follows:

JavaScript

I know the sampling frequency of the high frequency data (10 MHz), so each datapoint sample has a length of 100 nanoseconds. With the given time stamp of the acquisition, I can calculate back to give each of the data points a time stamp, spaced 100 nanoseconds.

In total I have hundreds of tousands of rows like above which I would like to convert in a nanosecond-precision time series which should look like follows:

JavaScript

Where N is the number of data points (= number of columns in the original frame = 13000) an M is the number of rows (= individial measurement data sets, each with 13000 data points)

Currently, my code looks as follows:

JavaScript

with

JavaScript

However, the data is not properly structured. I get an output_frame structured by M rows, each with one DataFrame containing a properly transformed high-frequency data time-series. How can I get to the “flat” structure of time indexed rows with one value and a time stamp?

As sample data it is enough to consider data like this (sample_frequency = 1E7):

JavaScript

This should become

JavaScript

Advertisement

Answer

I’m not sure I’m fully understanding the rebasing logic, but this does lead to from your sample input to your sample output.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement