How to List the Python Packages on TIBCO Cloud Spotfire


This topic applies only to users of TIBCO Cloud Spotfire Analyst.

When you create a data function for users to be able to run on TIBCO Cloud Spotfire, you might want to take advantage of some of the Python packages included on TIBCO Cloud Spotfire, as well as the packages that come installed with Python on your Analyst installation. Remember that if you use a Python package in an analysis on TIBCO Cloud Spotfire, that package must also be available on TIBCO Cloud Spotfire.

TIBCO Cloud Spotfire includes an archive containing many Python packages. You can retrieve this list, along with their versions, by creating a data function and saving it to TIBCO Cloud Spotfire.

To complete this task, you must meet the following prerequisites.

To create a data function that lists Python packages on TIBCO Cloud Spotfire:

  1. Open and log into TIBCO Cloud Spotfire Analyst.

    Comment: This version of Spotfire Analyst saves analyses to the library on TIBCO Cloud Spotfire.

  2. On the menu bar, click Tools > Register data functions.

    Response: The Register Data Functions dialog is displayed.

  3. In the Register Data Functions dialog, provide the following information.
    Name: Installed Python Packages.
    Type: Python script.
    Packages: Leave blank
    Description: Report the available Python packages.
    Allow caching: Clear the check box.
    Script tab:

    import pandas as pd

    import pkg_resources

     

    installed_packages = pkg_resources.working_set

    installed_packages_list = sorted(["%s==%s" % (i.key, i.version)

        for i in installed_packages])

    package_list = [[r.split('==')[0],r.split('==')[1]] for r in installed_packages_list]

     

    packages = pd.DataFrame(columns=["Package Name", "Package Version"])

    idx = 0

    for pkg in package_list:

        packages.loc[idx] = [pkg[0], pkg[1]]

        idx += 1

  4. Click the Output parameters tab.

  5. Click Add, and in the Output Parameter dialog, provide the following information:
    Result parameter name: packages.
    Display name: Installed Python packages.
    Type: Table.
    Description: A table of all of the Python packages installed.

  6. On the Register Data Functions dialog toolbar, click Run.

  7. In the Edit Parameters dialog, select  Refresh function automatically.
    Comment: You must select this check box, or your analysis displays only the packages available in your Spotfire Analyst installation.

  8. Click the Output tab, and for the Output handler, click Data table, and then click OK to accept the changes and run the data function.

  9. Click Close, and then click Yes to save the data function to the library on TIBCO Cloud Spotfire.

  10. On the authoring bar, click Visualization types and click Table to create a table visualization displaying all columns of the new Installed packages data table.

  11. Save the analysis to your library folder.

  12. Open the analysis in TIBCO Cloud Spotfire.
    Response: The table displays the available Python packages.

You can share this analysis with any members of your team who are interested in the available Python packages.

See also:

How to Use Data Functions