[SciPy-User] Joining 1D Timeseries to create a nD Timeseries
Sergi Pons Freixes
Sun Apr 11 16:34:57 CDT 2010
On Sun, Apr 11, 2010 at 8:17 PM, Pierre GM <email@example.com> wrote:
> On Apr 11, 2010, at 1:50 PM, Sergi Pons Freixes wrote:
>> Is there any elegant and fast way to join multiple unidimensional
>> timeseries to create a new one? E.g:
>> ts1 = timeseries 1D with param1
>> ts2 = timeseries 2D with param2
>> (ts1 and ts2 have same Date array)
>> newts = join_ts(ts1, ts2) ---> newts= timeseries 2D with param2, param2
> ts.stack should do the trick.
Thank you Pierre. It works when both timeseries have the same shape
(as I stated).
>> Or can this only be accomplished by creating a new timeseries, and
>> manually setting the date array and all the data at the creation time?
> Or you could try
> provided that you checked your series have the same dates and that there's no missing values. If the second condition is not met, use np.ma.column_stack instead (so that you don't lose the mask).
I prefer this approach, because it allows stacking timeseries with
different number of variables. In fact, my objective is to build a
multidimensional timeseries, stacking only a unidimensional timeseries
at a time.
The issue, now, is that if the timeseries dtypes have variable names
(e.g:, dtypes like ('foo', 'int32') instead of just 'int32'), the
np.column_stack crashes with a TypeError: expected a readable buffer
object. Maybe I should approach the building of the multidimensional
timeseries on a different way.
More information about the SciPy-User