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: 296 Dataiker
    edited July 17 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

Setup Info
    Tags
      Help me…