Using value of column (of a dataset) in email body
Hi Dataiku community,
I am attaching a dataset in an email notification after scenario ends as an excel file.
In the email body, how can I use a value of a column (which is date)? There are many records in the dataset but the value of one column is the same across the table and showing a date.
Thanks
Best Answer
-
JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 297 Dataiker
Hi @pafj
,There may be a few ways to do this; I've created a custom python step in a scenario that converts a dataset into a data frame, converts a timestamp to a string and replaces the current variable "date" with the first value in column "time_start". Note, you will need to create the global variable in your project first and the script below will update it.
import dataiku from dataiku import pandasutils as pdu import pandas as pd client = dataiku.api_client() project = client.get_project("project-key") mydataset = dataiku.Dataset("dataset") df = mydataset.get_dataframe() df['time_start'] = df['time_start'].astype(str) var = df['time_start'][0] #the variable must be created first variables = project.get_variables() variables["standard"]["date"] = var project.set_variables(variables)
Please let me know if you have any questions.
Thanks,
Jordan
Answers
-
Hi @JordanB
Thank you for taking the time and replying to my question.
I am pretty new to dataiku and I was wondering if you could direct me how to create a Global Variable in my project?
Thanks
-
CoreyS Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Registered Posts: 1,150 ✭✭✭✭✭✭✭✭✭
Hi @pafj
while you wait for Jordan's reply here are a few resources to get you started:- Concept: Variables 101 (Knowledge Base)
- Concept Summary: Defining Variables (Knowledge Base)
I hope this helps!
-
JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 297 Dataiker
Hi @pafj
,Corey has provided the documentation. You can navigate to your project variables from within the project menu. Variables should be in json format (as shown below).
Please let us know if you have any further questions.
Thanks!