[Numpy-discussion] Pandas LongPanel/WidePanel for 3d timeseries?
totalbull at mac.com
totalbull at mac.com
Sun Jan 17 18:49:17 EST 2010
Apologies - too quick to ask the list without thoroughly checking the online docs. I have found the answer (fromDict method takes DataFrame objects):
http://pandas.sourceforge.net/generated/pandas.WidePanel.html#pandas.WidePanel
Still would like to know how to append 2d matrices one-by-one though.
On 17 Jan 2010, at 23:43, totalbull at mac.com wrote:
> Hello,
>
> I am successfully using the new Pandas library for series and matrix analysis using 2 dimensional arrays. I am using the "fromDict" method which works well, and I am creating 2-dimensional arrays where each axis is indexed by FX currency names. So for example pandas DataFrame called aa:
>
>>>> aa.columns
> Index([AUDUSD, EURCHF, EURCZK, EURHUF, EURPLN, EURSEK, EURUSD, GBPUSD,
> NZDUSD, USDBRL, USDCAD, USDCLP, USDILS, USDJPY, USDKRW, USDMXN,
> USDRUB, USDSGD, USDTRY, USDTWD, USDZAR], dtype=object)
>>>> aa.rows
> <bound method DataFrame.rows of <class 'pandas.core.frame.DataFrame'>
> Index: 21 entries, AUDUSD to USDZAR
> Data columns:
> AUDUSD 20 non-null values
> EURCHF 20 non-null values
> EURCZK 20 non-null values
> EURHUF 20 non-null values
> EURPLN 20 non-null values
> EURSEK 20 non-null values
> EURUSD 20 non-null values
> GBPUSD 20 non-null values
> NZDUSD 20 non-null values
> USDBRL 20 non-null values
> USDCAD 20 non-null values
> USDCLP 20 non-null values
> USDILS 20 non-null values
> USDJPY 20 non-null values
> USDKRW 20 non-null values
> USDMXN 20 non-null values
> USDRUB 20 non-null values
> USDSGD 20 non-null values
> USDTRY 20 non-null values
> USDTWD 20 non-null values
> USDZAR 20 non-null values
>>
>>>> aa['USDZAR']['USDTWD']
> 1.2711725043942563
>>>>
>
> (each cell contains the number of standard errors of today's prices in the linear regression of the two currency pairs). Now I want to create a 3 dimensional stack of these aa-style matrices, where the z axis is indexed by historical dates. IE one matrix for each date, from today, going back 2 years. What is the best pandas function for doing this? Is it pandas.WidePanel or pandas.LongPanel, and how do I use these functions to construct this 3d stack? (I would ideally like to append each 2d matrix to the 3d stack as I create each one).
>
> Thanks for the help...... unfortunately can't find this in the online docs.
>
> Tom
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list