Visualizing Marketing Performance Data With the Tableau-like PyGWalker Library
Visualizing Ad Network Data with the Tableau-like Python library PyGWalker.

Visualizing Marketing Performance Data With the Tableau-like PyGWalker Library

In this article, I'll illustrate how marketing teams can effectively analyze and visualize performance data using PyGWalker. By leveraging PyGWalker, creating dynamic marketing dashboards - for example to compare Google, LinkedIn and TikTok Ads performance data - becomes simple, requiring just a few lines of code.

This approach is not only more accessible than delving into the complexities of Matplotlib but also presents a cost-effective alternative to paid analytics and business intelligence software.

Installing PyGWalker

The installation of the PyGWalker (https://kanaries.net/home/pygwalker ) library for Python is done by with following command line:

pip install pygwalker        

A comprehensive documentation for this can be found on GitHub: https://github.com/Kanaries/pygwalker

...

PyGWalker in Juypter Notebook

To create our first visualization in PyGWalker, there are various options available. The easiest way is to open a Jupyter Notebook. If you haven't installed Jupyter Notebook yet, today might be the best day to give it a try.

Install Jupyter Notebook with following command line:

pip install notebook        

Now, you can open a Jupyter Notebook by entering following command and following the instructions in your console:

jupyter notebook        

It should be noted that the Pyodide kernel is not capable of running PyGWalker. This is one of the main reasons why we didn't load the browser-based Jupyter Notebook. Instead, we'll now open a new notebook as a localhost and select the Python 3 (ipykernel).

More about getting started in Juypter Notebook here: https://jupyter.org/install

Now we're finally ready to utilize PyGWalker. We'll proceed by importing PyGWalker and Pandas, importing a CSV file containing dummy PPC data, and creating our initial dashboard with the "pyg.walk()" command.

import pandas as pd
import pygwalker as pyg

help(pyg)

df = pd.read_csv(r"C:\Users\Bj?rnThomsen\Desktop\pygwalker\your_export.csv", delimiter=',', skiprows=0, low_memory=False)

pyg.walk(df, dark="light")        

To minimize the need for data wrangling in Python, the report should include only one header row. Additionally, it's important to consider character encoding and correct number localization.

Now, in the Jupyter Notebook, we'll get our first PyGWalker dashboard. Under "Data" (top left), we can ensure that our CSV file has been correctly read, and if needed, we can modify dimensions and metrics.

With a click on "Visualization," we can create our first Tableau-like visualization. In the following example, we'll drag the dimension "GlobalCampaignID" onto the X-axis. Then, we'll place the metric "Clicks" on the Y-axis. Additionally, we can use filters to, for instance, filter out GlobalCampaignIDs without click data.

To further extract information from our visualization, indicating on which channel (Google, LinkedIn, or TikTok) these are attributed, we'll select the "Color" option for the Campaign "Type" dimension.

PyGWalker in Streamlit

Of course, we're not limited to Jupyter Notebook. Just as easily, after installing PyGWalker, we can generate the same dashboard and render it in Streamlit. For this, we'll first need to create Python file - importing Streamlit and creating a Dataframe from our CSV.

import streamlit.components.v1 as components
import streamlit as st
import pandas as pd
import pygwalker as pyg
 
st.set_page_config(layout="wide")
df = pd.read_csv(r"C:\Users\Bj?rnThomsen\Desktop\pygwalker\your_export.csv", delimiter=',', skiprows=0, low_memory=False)

pyg_html = pyg.to_html(df, dark="light")

components.html(pyg_html, height=1200, scrolling=True)        

Next, we create a streamlit application...

streamlit run C:\User\...\your_python_file.py        

Indeed, now we have the familiar view. Our Streamlit application displays our PyGWalker dashboard in HTML format. As previously introduced, we can use this according to our visualization needs.

In our example, we choose the box plot representation. With this, we can observe the standard deviations of "Clicks" depending on the Campaign (Type). This representation is, of course, less interesting for ad managers without knowing additional metrics such as conversions or costs.

Exporting PyGWalker Code

We naturally want to share our visualizations and the insights gained with our team. For this purpose, PyGWalker offers various export options. But, I find the most exciting option to be saving the generated views in Python or JSON format, allowing them to be loaded again if needed.

For this, we click on the (1) code icon in the menu bar, select (2) Python and (3) copy the generated code to clipboard,...

...and finally paste it into our original Python file with which we started the Streamlit application. If we use this file to render a new Streamlit application, it will generate the visualization we saved earlier.

Conclusion

I believe PyGWalker is a valuable library for low-code data visualization which helps marketers to gain valuable insights from their data and make informed decisions. Marketing teams lacking Data Science and Engineering capabilites (or budgets for PowerBI or Tableau) can generate useful visualizations independently with this library.

In contrast to Matplotlib, PyGWalker creates a dashboard with just a few lines of code, allowing it to be fully configured in the frontend using drag and drop.

Another advantage is that PyGWalker can be used not only in Jupyter but also as an application with Streamlit, Gradio, Plotly Dash, Flask, or Django.

However, I wouldn't want to overlook a significant disadvantage: the data analysis capabilities are rather rudimentary, and especially when reading CSV files, some data cleaning is required to ensure that the data is in the desired format.

Haitham Khalid

Manager Sales | Customer Relations, New Business Development

9 个月

Interesting find! How would you compare PyGWalker to other low-code data visualization tools?

要查看或添加评论,请登录

Bj?rn Thomsen的更多文章

社区洞察

其他会员也浏览了