Using value of column (of a dataset) in email body

Pasha
Pasha Dataiku DSS Core Designer, Registered Posts: 13 ✭✭✭

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
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 297 Dataiker
    edited July 2024 Answer ✓

    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

  • Pasha
    Pasha Dataiku DSS Core Designer, Registered Posts: 13 ✭✭✭

    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
    CoreyS Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Registered Posts: 1,149 ✭✭✭✭✭✭✭✭✭

    Hi @pafj
    while you wait for Jordan's reply here are a few resources to get you started:

    I hope this helps!

  • JordanB
    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).

    Screen Shot 2022-10-28 at 3.07.13 PM.png

    Screen Shot 2022-10-28 at 3.08.39 PM.png

    Please let us know if you have any further questions.

    Thanks!

Setup Info
    Tags
      Help me…