Pulling data from Analysis¶
In [ ]:
Copied!
#To get a copy of this notebook in your current working directory, run:
from pycelonis.notebooks import api_tutorial
#To get a copy of this notebook in your current working directory, run:
from pycelonis.notebooks import api_tutorial
1. Connect to Celonis¶
In [ ]:
Copied!
from pycelonis import get_celonis
celonis = get_celonis()
from pycelonis import get_celonis
celonis = get_celonis()
2. Connect to an analysis in Celonis that contains the OLAP table¶
find the analysis by either searching for the analysis's name or ID.
In [ ]:
Copied!
analysis = celonis.analyses.find('440cb0ba-7f00-4ec9-a50a-f9f8772e5893')
analysis
analysis = celonis.analyses.find('440cb0ba-7f00-4ec9-a50a-f9f8772e5893')
analysis
3. Find the OLAP table¶
Find the table that you want to extract through the table's name.
In [ ]:
Copied!
component = analysis.draft.components.find("Vendors")
component
component = analysis.draft.components.find("Vendors")
component
4. Extract the OLAP table¶
Extract the OLAP table with the get_data_frame() function.
In [ ]:
Copied!
df = component.get_data_frame()
df.head()
df = component.get_data_frame()
df.head()
5. Advanced: Add filters and variables from "Share your selections"¶
Make a selection and/or change variables and copy the url via the shared selection tab to your clipboard and the post it into the cell below.
In [ ]:
Copied!
url = "https://ml-appstore.eu-1.celonis.cloud/process-mining/analysis/440cb0ba-7f00-4ec9-a50a-f9f8772e5893/link/frontend/documents/440cb0ba-7f00-4ec9-a50a-f9f8772e5893/view/sheets/5066b16f-f342-4be4-a70c-b744684e5ac3/b/0dd91c45-73c2-4312-93c5-d7602bcc640b"
selection = analysis.process_shared_selection_url(url)
# **Add the selection query to the component query and pull the data from the analysis**
url = "https://ml-appstore.eu-1.celonis.cloud/process-mining/analysis/440cb0ba-7f00-4ec9-a50a-f9f8772e5893/link/frontend/documents/440cb0ba-7f00-4ec9-a50a-f9f8772e5893/view/sheets/5066b16f-f342-4be4-a70c-b744684e5ac3/b/0dd91c45-73c2-4312-93c5-d7602bcc640b"
selection = analysis.process_shared_selection_url(url)
# **Add the selection query to the component query and pull the data from the analysis**
In [7]:
Copied!
query = component.pql_query
query += selection
analysis.get_data_frame(query)
query = component.pql_query
query += selection
analysis.get_data_frame(query)
Out[7]:
LFA1.LIFNR | LFA1.LAND1 | |
---|---|---|
0 | SORAYA45 | ES |
1 | SP-CARA | IT |
2 | SP-CARB | IT |