Closed meyersrl closed 6 years ago
I think you may have missed something. The DataFrame is made up of columns. One Column per dimension and one for the values.
If not told otherwise the build_pandas_dataframe_from_cellset
function returns a multiindex dataframe.
If you want to normal dataframe just pass multiindex=False
as an argument to the function:
from TM1py import TM1Service
from TM1py.Utils import Utils
with TM1Service(address='localhost', port=12354, user='admin', password='apple', ssl=True) as tm1:
mdx = "SELECT {" \
"[plan_chart_of_accounts].[Other Expenses]," \
"[plan_chart_of_accounts].[Payroll]," \
"[plan_chart_of_accounts].[Travel]," \
"[plan_chart_of_accounts].[Depr & Amort]," \
"[plan_chart_of_accounts].[Adv & Marketing]} on ROWS, " \
"{[plan_time].[Q1-2004],[plan_time].[Q2-2004],[plan_time].[Q3-2004],[plan_time].[Q4-2004]} on COLUMNS " \
"FROM [Plan_BudgetPlan] " \
"WHERE ([plan_version].[FY 2004 Budget],[plan_department].[105],[plan_exchange_rates].[local]," \
"[plan_source].[input],[plan_business_unit].[10110]) "
data = tm1.data.execute_mdx(mdx)
df = Utils.build_pandas_dataframe_from_cellset(data, multiindex=False)
# print full dataframe
print(df)
# print one column
print(df[["plan_chart_of_accounts"]])
The multiindex=False did the trick. Made it feel more like a straight table vs the multiindex dataframe which was hard to visually tell where the columns were
It appears the pandas dataframe brings in all the data but there are no column splits. Any chance you could modify the code to split the data into columns? Or possibly I have missed something and there is a way. I was about to head down the path of parsing the columns either from the string data thats returned or the dataframe