Python Pandas library
(Redirected from PyExplodeDataFrame)
new to Analytica 7.0
The Python Pandas library contains functions to assist with using the Pandas library (a common Python library) from within your Analytica model.
PyExplodeDataFrame(dataFrame, columns, rows, separator, byPosition)
Use this function to convert a Pandas DataFrame into an Analytica multidimensional table, optionally matching each DataFrame axis to provided Analytica Indexes either by label (default) or by position.
- «dataFrame»
- The Pandas DataFrame to convert into an Analytica array.
- «columns»
- One or more Analytica Indexes corresponding to the «dataFrame»'s column axis, ordered from outermost to innermost level.
- When specified, the number of provided Indexes must match the number of MultiIndex levels, otherwise an error is thrown.
- If the column axis is a MultiIndex and «columns» is provided, each MultiIndex level becomes a separate Analytica dimension.
- If «columns» is omitted, a local index is created from the labels of the «dataFrame»’s column axis. For a MultiIndex, the levels are flattened into a single set of labels joined by «separator».
- «rows»
- One or more Analytica Indexes corresponding to the «dataFrame»'s row axis, ordered from outermost to innermost level.
- When specified, the number of provided Indexes must match the number of MultiIndex levels, otherwise an error is thrown.
- If the row axis is a MultiIndex and «rows» is provided, each MultiIndex level becomes a separate Analytica dimension.
- If «rows» is omitted, a local index is created from the labels of the «dataFrame»’s row axis. For a MultiIndex, the levels are flattened into a single set of labels joined by «separator».
- «separator»
- Used only when a local index is created for a MultiIndex axis; joins the labels from multiple levels into a single flat label. Ignored when the axis is not a MultiIndex or when explicit Indexes for an axis are provided.
- «byPosition»
- False — Matches «dataFrame» axes to provided Analytica Indexes by label.
- The order of Analytica Index items determines the order of values in the result — data is reordered if labels are out of order.
- Extra Analytica Index items not present in the «dataFrame» labels are null padded; labels in the «dataFrame» but not in the Analytica Index are dropped.
- Matching is applied independently to each axis and to each MultiIndex level.
- NOTE: Each Index's identifier must exactly match a level name in the MultiIndex
- Example:
DataFrame ['One','tWo','thRee'] → [1, 2, 3]with Analytica Index['thRee','tWo','one']gives[3, 2, Null]. - The Analytica Index label 'one' is not found and is therefore nullpadded. The label 'One' in «dataFrame» is not found in the Analytica Index and is therefore dropped.
- True — Matches «dataFrame» axes to Analytica Indexes by position, ignoring label names.
- The first provided Analytica Index corresponds to the first MultiIndex level, the second to the second level, etc.
- Each Index length must exactly match the length of the corresponding MultiIndex level, or an error is thrown.
See also
Comments
Enable comment auto-refresher