Using Pandas with PyMPX ------------------------ Importing the :mod:`pympx` module will add extra functionality to the :mod:`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 :meth:`pd.read_empower` returns a pandas DataFrame in the same way that :meth:`pd.read_csv` does: .. notebook:: ..\pympx\doc\examples\reading_a_dimension_into_a_pandas_dataframe.ipynb 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. .. image:: _static/using_autocomplete_in_jupyter.png :align: center :meth:`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 .. notebook:: ..\pympx\doc\examples\creating_elements_from_csv_using_pandas.ipynb Creating a hierarchy from a flat list in a pandas DataFrame ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Hierarchy structure can be loaded from pandas DataFrames. The following example notebook can be found in pympx\doc\examples\creating_a_hierarchy_using_embellish_method.ipynb : .. notebook:: ..\pympx\doc\examples\creating_a_hierarchy_using_embellish_method.ipynb .. autofunction:: ~pympx.pympx.to_empower_viewpoint