publish() method

Saves a Pandas or HCL dataframe to an Activity Center dataset.

Syntax

hcl.publish(dataframe_name, table_name = AC_dataset_name, column_names = {"column_name":"dataset_display_name", "...n":"...n"}|dictionary_object, append = True|False)

AC = Activity Center

Parameters

Name Description
dataframe_name

The name of the Pandas or HCL dataframe to save to Activity Center.

All columns in the dataframe are saved. If you want to save only a selection of the columns, create an appropriately configured dataframe first, before using publish().

table_name = AC_dataset_name

The name of the Activity Center dataset.

Note

Review the names of existing datasets in Activity Center and make sure to specify a dataset name that is unique. The publish() method does not prevent you from specifying a duplicate dataset name, which can create a confusing situation in Activity Center.

column_names = {"column_name" : "dataset_display_name", "...n" : "...n"}

optional

A mapping between a column name in the dataframe and a display name for the corresponding field in the Activity Center dataset.

Construct the mapping for one or more columns using a standard Python dictionary.

You are specifying a display name only for the field in the destination Activity Center dataset. The underlying field name in Activity Center remains unchanged.

You can choose to specify display names for only a subset of columns. Columns without a specified display name use the dataframe column name in Activity Center.

The column_names parameter does not select which columns are saved. By default, the publish() method saves all columns in the dataframe to Activity Center.

Note

Make sure the display names that you specify are unique. The publish() method does not prevent you from specifying a duplicate display name. However, publication to Activity Center fails.

For more information, see Column and display names must be unique.

column_names = dictionary_object

optional

A pre-existing dictionary object that maps one or more column names in the dataframe to display names for the corresponding fields in the Activity Center dataset.

As an alternative to creating the column mapping inside publish(), you can create the mapping in a separate dictionary and specify only the dictionary name inside publish(). If you need to create the same set of display names for multiple destination datasets in Activity Center, this approach is more efficient.

The guidelines that apply when creating a dictionary inside publish() also apply when creating a separate dictionary.

append = True | False
  • True Saved data is appended to any existing data in the Activity Center dataset.
  • False Saved data overwrites any existing data in the Activity Center dataset.

If you omit the parameter, saved data overwrites any existing data by default.

Returns

For success, the return code 204. For failure, an error message.

The return code 204 means that Robots has successfully sent the data to Activity Center. Subsequent data processing in Activity Center must also be successful before the data sent from Robots is available as a dataset in Activity Center.

Examples

Save a dataframe to an Activity Center dataset

You save the customer_summary dataframe to an Activity Center dataset called Customer. If the Customer dataset already exists in Activity Center, existing records are overwritten.

hcl.publish(customer_summary, table_name = "Customer")

Remarks

Column and display names must be unique

To successfully publish data from Robots to Activity Center, dataframe column names must be unique. A duplicate column name in a dataframe causes the publish() method to fail with an error message.

If you specify display names for fields in an Activity Center dataset, the display names must also be unique. A duplicate display name does not cause the publish() method to fail, and a script containing the method runs to completion. However, subsequent data processing fails, and publication to Activity Center is not successful.

Scope of publishing capability

Write permissions for Activity Center datasets created from Robots are robot-based. To update a dataset, you must use the same robot that initially created the dataset. The publish() method does not support crossing robot boundaries when updating datasets.

Automatic addition of publication date and time

The publish() method automatically includes the date and time of publication with the data sent to Activity Center. When you add the data as a table to an analysis and a dashboard in Activity Center, include the Published At field to display the most recent publication date and time, dynamically updated, for each record in the table.

This timestamp information is useful for verifying that a scheduled publication from Robots executed at the expected date and time. If you append records to a dataset, the timestamp information also shows when each record was appended, and allows you to sort by timestamp.