How to enable Autocompletion in Jupyter Notebook application

With the rise of Data Scientists, Financial coders, Casual Developers, or Traders (aka Citizen Developers), and the rapid growth of Jupyter application, Jupyter Notebook and its next-generation, JupyterLab is a de-facto tool of those Citizen Developers. Thanks to the IPython kernel, Notebook provides a powerful interactive shell, interactive data visualization, embedded documentation, and supports various programming languages such as Python (native supported), R, Julia, and much more.

The Notebook application is easier to use when comparing to other traditional IDEs (Integrated development environment) or Editors. Citizen Developers do not need much programming language or technology experience to use the Notebook application. However, The Jupyter Notebook also provides Coding and Magic features which make Notebook a friendly development environment for both Citizen and Professional Developers.

This article demonstrates how to enable Python/Jupyter application coding autocompletion feature. The demo application uses content from the Refinitiv Data Platform (RDP) as an example library.

Refinitiv provides a wide range of contents and data which require multiple technologies, delivery mechanisms, data formats, and the multiple APIs to access each content. The RDP Libraries are a suite of ease-of-use interfaces providing unified access to streaming and non-streaming data services offered within the Refinitiv Data Platform (RDP). The Libraries simplified how to access data to various delivery modes such as Request-Response, Streaming, Bulk File, and Queues via a single library.

Depending on the level of service and data requirements, developers can easily choose how to access data services using the appropriate access channel defined within the library.

RDP Libraries Diagram
RDP Libraries Diagram

Using the library developers can access content from all 3 of the access points — all from within the same application if required. The RDP Libraries are available in the following programming languages:

  • Refinitiv Supported Editions: Python and TypeScript/JavaScript (coming soon)
  • Community-based Edition: C#

For more deep detail regarding the RDP Libraries, please refer to the following articles and tutorials:

As this notebook is based on alpha version 1.0.0a7.post7 of the Python library, the method signatures, data formats, etc. are subject to change.

You can install RDP Libraries — Python and JupyterLab in your environment with the following basic pip command:

$>pip install refinitiv-dataplatform==1.0.0a7.post7 jupyterlab

The Python programming language comes with a built-in help() function to display documentation of modules, functions, classes, objects, etc with the following syntax:

help([object])

However, the result is not always easy to read as the following examples:

Figure-1
Python help on RDP object

or

Figure-2
Python help on RDP open_platform_session function

For the library that keeps involving like RDP Libraries, this is inconvenient even the RDP Library itself is easy to use.

Fortunately, the JupyterLab and Jupyter Notebook comes with the IPython magic command %config Completer.use_jedi = False that enables the library/function autocompletion (like IntelliSense in Microsoft development environment term).

You need to set the magic command %config Completer.use_jedi = False at the top cell of the Notebook application (like this Notebook).

Figure-3
IPython Magic command location

Once you have enabled and run the %config Completer.use_jedi = False magic command, you can trigger the code autocompletion by pressing the tab button after the "." character.

Figure-4
RDP with IPython Autocompletion

The magic %config Completer.use_jedi = False command also enables the "shift + tab" buttons to show the function help and tooltip information.

Figure-5
RDP with IPython function Autocompletion

These autocompletion shortcuts also support the library properties/attributes as well.

Figure-6
RDP with IPython attributes Autocompletion

Please note that all IPython helpers and autocompletion magic support all Python libraries in the Notebook environment, not limit to only RDP Libraries.

Figure-7
Pandas DataFrame with IPython Autocompletion

If you are Refinitiv Workspace or Eikon user, you can access CodeBook, the cloud-hosted Jupyter Notebook development environment for Python scripting from the application. The CodeBook is natively available in Refinitiv Workspace and Eikon as an app (no installation required!!), providing access to Refinitiv APIs that are already pre-installed on the cloud.

One benefit of using the CodeBook app is the environment has already enabled Jupyter Notebook magics for you. You can use all code autocompletion shortcuts (tab, shift + tab, and ?) without setting any IPython Magic in your Notebook.

Figure-8
CodeBook Autocompletion

Please see more detail regarding the CodeBook app in this Use Eikon Data API or RDP Library in Python in CodeBook on Web Browser article.

Prerequisite

This demo project requires the following dependencies software.

  1. RDP Access credentials.
  2. Refinitiv Data Platform Library for Python.
  3. Python Anaconda or MiniConda distribution/package manager.
  4. Jupyter Notebook or JupyterLab.
  5. Internet connection.

Please contact your Refinitiv’s representative to help you to access Refinitiv Data Platform credentials. You can generate/manage the AppKey from the AppKeyGenerator website or AppKey Generator tool in Eikon Desktop/Refinitiv Workspace application.

How to run the example

Please unzip or download the example application from GitHub into a directory of your choosing, and then follow the step-by-step instruction in Running the example Notebook of the project README.md file.

Some Professional Developers may think Jupyter Notebook (and JupyterLab) is just a learning tool for Casual Developers like Data Scientists. However, the tool provides enough coding/development features for a wide range of Developers. The IPython Code Autocompletion feature (and other Magics) helps developers implement the code logic and navigate through the libraries/APIs in the same experience as the traditional IDEs.

There is some new development project that tries to merge the benefits/features of the traditional IDEs and Jupyter Notebook like Netflix’s Polynote. While the JupyterLab also keeps evolving to make a better development environment and easier to use.

At the same time, the Refinitiv Data Platform (RDP) Libraries let developers rapidly access Refinitiv Platform content with a few lines of code that easy to understand and maintain. Developers can focus on implement the business logic or analysis data without worry about the connection, authentication detail with the Refinitiv Platforms.

You can find more details regarding the Refinitiv Data Platform Libraries and Jupyter Notebook from the following resources:

For any questions related to this article or Refinitiv Data Platform Libraries, please use the Developers Community Q&A Forum.

https://github.com/Refinitiv-API-Samples/Article.RDPLibrary.Python.NotebookAutoCompletion

Developer Advocate at Refinitiv, an LSEG business. https://developers.refinitiv.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store