JupyterLab Extension for INFACore

JupyterLab Extension for INFACore

Read data and convert to Pandas DataFrame

Read data and convert to Pandas DataFrame

You can read from a data source and convert the data to a Pandas DataFrame.
You can configure the read and Pandas operations on the
Apply Functions
tab. When you configure a read operation, select the data source and connection, and then enter the data source object name from where you want to read data.
If you have already select the data source and connection, and then configure the read operation, the data source and connection are prepopulated in the Read operation dialog box.
In this example, we use a Snowflake connection to read customer data from a Snowflake source.
  1. On the
    General
    tab, select
    Read
    .
  2. Select the data source and the connection for the data source.
  3. Enter the path to the source data object from where you want to read data.
  4. Click
    Submit
    . You enter the data source name, the connection names, along with the object name to generate the read function code in the workspace.
    The following code appears in the JupyterLab workspace. You can run the code to read the data.
    read_data_object = ic.get_data_source("Snowflake").get_connection("SnowConn").get_data_object("CONDLT/DLT_SCHEMA_01/CUSTOMERS") table = read_data_object.read().collect()
  5. To convert the data from the INFACore DataFrame to the Pandas DataFrame, select
    To Pandas
    . You enter the table variable name to generate the code to convert the DataFrame to the Pandas DataFrame in the workspace.
  6. Enter the variable name as table, and click
    OK
    .
    The following code appears in the JupyterLab workspace. You can run the code to read the data.
    df_reader = ic.DataFrameReader(table) p_df = df_reader.to_pandas()
  7. To print the results, enter the following code:
    p_df.head()
When you run the code, the SDK returns the following data for the read operation:
You can view the data read from the source.
To use the INFACore SDK for python directly to extract data from a data source, call the read() method on the DataObject instance and then invoke the to_pandas() method to convert the INFACore DataFrame to the Pandas DataFrame.

0 COMMENTS

We’d like to hear from you!