to_hb_results() method

Saves an HCL dataframe to a Results table.

Note

Using the to_hb_results() method requires that you also create a password variable called v_hb_token in the Variables window in the HCL script editor and assign a HighBond API token as the variable value. For more information, see Use the Variables window to define an HCL variable.

Syntax

dataframe_name.to_hb_results(table_id = Results_table_ID_number, column_names = {"column_name":"Results_display_name", "...n":"...n"}|dictionary_object, overwrite = True|False)

Parameters

Name Description
table_id = Results_table_ID_number The numeric ID of the Results table.
column_names = {"column_name" : "Results_display_name", "...n" : "...n"}

optional

A mapping between a column name in the dataframe and a display name for the corresponding field in Results.

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 Results table. The underlying field name in Results remains unchanged.

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 Results.

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

You are specifying a display name only for the field in the destination Results table. The underlying field name in Results remains unchanged.

overwrite = True | False
  • True Saved data overwrites any existing data in the Results table.
  • False Saved data is appended to any existing data in the Results table.

If you omit the parameter, saved data is appended by default.

Returns

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

Examples

Save a dataframe to a Results table

You save the customer_summary dataframe to the Results table with ID 587293. Any existing records in the Results table are overwritten.

customer_summary.to_hb_results(table_id = "587293", overwrite = True)

Save a dataframe and create field display names in Results

You save the customer_summary dataframe to the Results table with ID 587293. At the same time, you create three display names for fields in the destination Results table.

In Results:

  • The No field uses the Customer Number display name
  • The First field uses the First Name display name
  • The Last field uses the Last Name display name
customer_summary.to_hb_results(table_id = "587293", column_names = {"No":"Customer Number", "First":"First Name", "Last":"Last Name"}, overwrite = True)

Save multiple dataframes and create field display names using a pre-existing dictionary

You use a single dictionary object ( display_names ) to create the same set of display names in three Results tables.

display_names = {"No":"Customer Number", "First":"First Name", "Last":"Last Name"}
customer_summary_us.to_hb_results(table_id = "587293", column_names = display_names, overwrite = True)
customer_summary_eu.to_hb_results(table_id = "587294", column_names = display_names, overwrite = True)
customer_summary_ap.to_hb_results(table_id = "587295", column_names = display_names, overwrite = True)

Remarks

Data type mapping

When you save an HCL dataframe to a table in Results, column data types in the dataframe are automatically mapped to field data types in the table:

Column data type in HCL dataframe Field data type in Results table
object character
category character
int64 numeric
float64 numeric
datetime64[ns] datetime
timedelta64[ns] numeric
bool logical

Automatic removal of metadata and extras fields

If a data analysis workflow round-trips data from Results to Robots and back to Results, metadata and extras fields in an HCL dataframe are automatically removed from the data that is saved back to Results. The fields are removed whether you save the HCL dataframe back to the same table in Results, or to a new table.

metadata and extras fields are system-generated fields in Results and are protected. The content in these fields, if editable, can only be edited in Results. For this reason, you are preventing from overwriting or appending to these fields from Robots.

Note

When you save round-tripped data back to Results, metadata and extras fields do appear with the saved data. However, these are new fields automatically created by Results. They are not the fields as they exist in Robots.

The following metadata and extras fields, if they exist in Robots, are automatically removed from the saved data:

  • metadata.priority

  • metadata.status

  • metadata.publish_date

  • metadata.publisher

  • metadata.assignee

  • metadata.group

  • metadata.updated_at

  • metadata.closed_at

  • extras.record_id

  • extras.collection

  • extras.results_table