cubewise-code / tm1py

TM1py is a Python package that wraps the TM1 REST API in a simple to use library.
http://tm1py.readthedocs.io/en/latest/
MIT License
187 stars 107 forks source link

Hierarchy/ Parent-Child relationship using TM1py #1064

Closed Dashon32 closed 5 months ago

Dashon32 commented 6 months ago

Describe what did you try to do with TM1py I am writing a script to get the parent-child relationship and also a flattened hierarchy which will be exported as a pandas dataframe. I have seen the _get_elementsdataframe function, but don't find it suitable to get a parent-child relationship out of it. What I want is a simple data frame of 4 columns - Parent ID, Parent Attribute, Child ID, and Child Attribute. Is there a pre-existing function that already does that in TM1Py? If not what can be an efficient workaround?

For the flattened hierarchy as well is there a way to get all levels with their single attribute, something like this - Level 0, Attribute Level 0, Level 1, Attribute Level 1 etc

MariusWirtz commented 5 months ago

You could use the get_elements_dataframe function as a starting point and retrieve the parent attribute values in a separate post-processing step. In terms of lines of code, this should be the easiest solution.