Skip to main content

Integrating Cognos Analytics and Jupyter Notebook in practice

A step-by-step example: reading Cognos data with pandas, profiling it, building Python visualizations and adding them to a dashboard.

Using a customer churn example, this article shows how Jupyter Notebook works inside IBM Cognos Analytics: combining files into a pandas dataframe, exploring them with a profiling report, building visualizations with Python libraries and bringing those outputs into a dashboard tab alongside native Cognos visualizations.

Series «Cognos Analytics and Jupyter Notebooks», part 2 of 2. Part 1 · Part 2

This second part walks through a hands-on example of working with Jupyter Notebook inside IBM Cognos Analytics: reading Cognos data with pandas, exploring and profiling it, building visualizations in Python and bringing those outputs into a Cognos dashboard. The first part covered the steps, requirements and benefits of the integration.

Reading and combining Cognos data in a notebook

The following image shows how the files I had already uploaded to Cognos Analytics are read and then combined into a single pandas.DataFrame (a data structure in the pandas library that handles data as if it were a table).

If you want, you can save the combined files as a new file in IBM Cognos and read it back to continue the analysis.

Exploring and profiling the data with pandas

At this point the data for the analysis is in the “churn_data_merge” dataframe. You can apply different functions to this object to explore the data, such as viewing the first ten records:

Or a function that describes the variables:

You can also install packages, such as one for data profiling:

Among many other things, the report shows the types of variables found. For example, it reports 56 variables: 23 Boolean, 18 numeric and 15 categorical, plus the number of cells with null values.

It also flags variables with high percentages of zero or null values, and variables with high correlation or high cardinality.

Building visualizations in Python

With the data in a pandas dataframe, you can use all of that object’s features to explore and analyze it. As mentioned, you can also build visualizations; some of the libraries available are Matplotlib, pandas visualization, Seaborn and Plotly. Here is an example:

The code above produces this output:

You can also build more elaborate visualizations, like this one (Churn Category and Churn Reason Overview):

Bringing notebook outputs into a dashboard

Best of all, these visualizations, like any notebook output, can be inserted into a dashboard, story or report. For example, here is a dashboard:

We can add another tab with the visualization built in the notebook. The widgets now include an Advanced section for adding a notebook:

Once you pick the notebook, you can choose the output you need from all of its outputs and add it to the dashboard tab.

The next image shows the notebook output in the new tab; the top right corner shows when the imported output was last updated.

If you prefer, you can also combine Cognos and notebook visualizations in the same tab. The one on the left is from Cognos and the one on the right is from a notebook.

What skills you need

Using Jupyter Notebooks takes programming and statistics skills (along with Python’s libraries) to carry out data science tasks and get the most out of the tool. Visualizations aren’t built as naturally as in a dashboard or report (by dragging items from a data source onto a chart): they require that programming knowledge, plus familiarity with the data structures and libraries involved.

As you can see, IBM Cognos Analytics and Jupyter Notebooks work in both directions. You can create a notebook, pull data from Cognos, analyze and transform it to produce new content (data and visualizations), and then use it in IBM Cognos Analytics tools.

Marcelo Celio
Computer Engineer / Data & Analytics consultant

¿Listo para dar
el próximo paso?

Inicia tu camino
Otras publicaciones

Before asking how to use AI in a utility, it is worth asking whether the data is ready to support better decisions.

Six connected stages take a public power finance function from assessment to adoption, so AI can support better, faster and more traceable decisions.

Affordability, capital investment and resilience are now moving together. Utilities need scenarios to make decisions before the future becomes clear.

Quanam, a digital transformation, data and AI consultancy headquartered in Montevideo, Uruguay, is Certified in the Claude Partner Network. Its team holds Claude certifications, part of a path guided by one conviction: AI delivers more when people work alongside it.

Leave a Reply