Using Pandas with PyMPX
Importing the pympx
module will add extra functionality to the pandas
module.
The extra functions behave in a similar way to pd.read_csv() and pd.DataFrame.to_csv()
Reading from Empower into a pandas DataFrame
For example pd.read_empower()
returns a pandas DataFrame in the same way that pd.read_csv()
does:
import pandas as pd
from pympx import pympx as mpx
site = mpx.Site(r"C:\Empower Sites\Sunrise Brands Limited\Sunrise Brands Limited.eks")
df = pd.read_empower(site.dimensions[0])
df.head()
ID | Short Name | Long Name | Description | Group Only | Calculation Status | Calculation | Colour | Measure Element | NewField | ... | Geography3 | Geography4 | Geography5 | Geography6 | Geography7 | Geography8 | Geography9 | Geog_L1 | Geog_L2 | Geog_L3 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | ALL | ALL | None | None | Real | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
1 | 2 | TMarkets | Global Markets | None | None | Real | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
2 | 3 | NA | North America | North America | None | Real | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
3 | 4 | Europe | Europe | Europe | None | Real | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
4 | 5 | UK | UK | United Kingdom | None | Real | None | None | None | None | ... | None | None | None | None | None | None | None | None | None | None |
5 rows × 30 columns
The returned dataframe contains the standard Empower fields, and the Empower custom fields. In the example above NewField
is an Empower custom attribute. The column ID
contains the Empower physid.
Tip
Typing the dot (.) symbol and then the [TAB] key will bring up the pandas autocomplete. If you type part of a method name you can see the matching methods in the dropdown list.

pd.read_empower()
appears in the dropdown along with the standard pandas read functions.
Creating elements from csv, via a pandas DataFrame
Elements can be created from csv very easily, via a pandas DataFrame.
The one difficulty is to know that the DataFrame’s columns need renaming to the standard dimension field names
Short Name
Long Name
Description
Group Only
Calculation Status
Calculation
Colour
Measure Element
…and custom field longnames