Photo by editor
# Introduction
Today everyone works with tons of data. We all have love Pandas For data wrangling. But let’s be honest, scrolling through data frames and manually plotting charts gets boring. The routine rarely changes: load a data frame, inspect some columns, run describe()and create the same set of charts to look for patterns. It works, but it’s repetitive and time consuming. I noticed during a recent project when I spent the first two hours using basic histograms, scatter plots, and correlation visuals to answer simple questions about distributions and relationships.
Lux is a python library that integrates directly with pandas and Automatically generates intuitive visualizations as you display data frames. It does not change the analytical reasoning. Rather, it removes the manual work that delays it. It helps analysts, students and data scientists quickly explore data, discover trends and understand patterns before they even start modeling. In this article, we’ll explore how Lux works, how to set it up, and why it is. The perfect companion for “lazy” analysts Those who still want smart results.
# Installation
Before we understand how Lux works, let’s install Lux and activate it in our notebook environment (Jupiter/Google Collab). You can install it using the following PIP:
!pip install lux-api
!pip install lux-widgetNext, import as you normally would with pandas:
import pandas as pd
import luxIf you’re using Google Collab, you’ll also need to enable the widget manager:
from google.colab import output
output.enable_custom_widget_manager()Once imported, Lux automatically hooks into your Pandas environment.
# Why luxury?
A traditional exploratory data analysis (EDA) workflow is:
df.head()
df.describe()
sns.pairplot(df)
df(col).hist()
plt.scatter(df(x), df(y))It’s repetitive and slow. Lux changed it:
Lux examines your data and creates recommended charts based on distributions, correlations, trends, and patterns, as well as data types. Basically, Lux acts as an intelligent assistant that suggests what to watch next.
# How does Lux work?
Now, let’s see a simple example using this COVID Dataset:
url = "
df = pd.read_csv(url)
dfWhen a data frame is displayed, Lux automatically examines its structure and creates a meaningful visualization underneath.
Output:![]()
![]()
If you click Toggle Pandas/Lux, you see something like this:![]()
![]()
You can switch between tabs to view correlation, distribution, temporal and geographic charts. Let’s understand what each of these tabs means:
- Correlation: It shows how the number of confirmations, recoveries and deaths are related to each other.
- Distribution: Highlighted is how case numbers tend to spread out in spot patterns or abnormal values.
- mundane: Tracks changes in cases over time, making it easy to spot peaks and spikes.
- Geographical: Shows where cases are most common in countries and regions.
This is done without writing any plotting code. Lux easily adds to the default data frame display to help you quickly find key patterns.
# Save all Lux concepts as HTML
Lux makes it possible to export the entire visual panel into a shareable interactive HTML file:
df.save_as_html("lux_report.html")Output:
Saved HTML to lux_report.htmlNow you can download and view this file in any browser.![]()
![]()
You can also guide Lux to focus on specific relationships within your dataset by setting an intent.
# Exploring data with intent
Let’s use the same dataset to understand this. Suppose you want lux to emphasize authenticated cases. You can do this by:
df.intent = ("Confirmed")
dfOutput:![]()
![]()
When you set an intention, Lux focuses on the columns you care about. It then shows charts that clearly compare the different groups. This makes it easier to note patterns. You can test ideas faster and understand your data more clearly.
Lux also gives you the option to export suggested visualizations.
# Export concepts
Lux allows you to extract any concept you find interesting directly from the widget. Just click on the chart you want and then select the Export button.![]()
![]()
are stored in exported concepts df.exported. To display the full list of saved visuals, use:
Output:

If you want to look at a specific exported chart, just access it by index like this:
# Get the first exported visualization
vis = df.exported(0)
visOutput:

Lux automatically converts the visualization to MatplotLab, Altair, or VegaLite code. You can reuse and customize it without manually writing long plotting scripts.
# Get the equivalent plotting code
print(vis.to_matplotlib())
print(vis.to_altair())
print(vis.to_vegalite())For example, output print(vis.to_matplotlib()) will be:
import matplotlib.pyplot as plt
plt.rcParams.update(
{
"axes.titlesize": 20,
"axes.titleweight": "bold",
"axes.labelweight": "bold",
"axes.labelsize": 16,
"legend.fontsize": 14,
"legend.title_fontsize": 15,
"xtick.labelsize": 13,
"ytick.labelsize": 13,
}
)
import numpy as np
from math import nan
df = pd.DataFrame({'Confirmed': {0: 0.0, 1: 8062512.0, 2: 16125024.0, 3: 24187536.0, 4: 32250048.0, 5: 40312560.0, 6: 48375072.0, 7: 56437584.0, 8: 64500096.0, 9: 72562608.0}, 'Number of Records': {0: 119202.0, 1: 917.0, 2: 399.0, 3: 220.0, 4: 212.0, 5: 122.0, 6: 25.0, 7: 7.0, 8: 7.0, 9: 65.0}})
fig, ax = plt.subplots()
bars = df('Confirmed')
measurements = df('Number of Records')
ax.bar(bars, measurements, width=6718760.0)
ax.set_xlabel('Confirmed (binned)')
ax.set_ylabel('Number of Records')
fig# When Lux Is Useful (and When It’s Not)
When you’re trying to understand your dataset and uncover early patterns, Lux Research is helpful during the early stages of data analysis. It increases understanding of data, speeds up hypothesis building, and works great for teaching and quick research tasks. By automating the first layer of visual discovery, Lux reduces the time spent writing basic plots and lets you focus more on interpreting insights than dealing with plotting code. As with many pros, Lux also has some limitations, which are described as:
- It works best within Jupiter Notebook, Google Collab, or JupiterLab.
- This is not ideal for very large datasets.
- Publication-ready visualizations still require tools like MatplotLab, Seaborne, or Altair.
# The result
If you’re learning data analysis, Lux is a great way to get intuitive quickly. Good tools don’t replace expertise. They help you develop it. Instead of spending time on basic charts, you can jump right into understanding your dataset. If you face any difficulty while exploring it, reach in the comment section. Some helpful resources you may find are:
Kanwal Mehreen is a machine learning engineer and technical writer with a deep passion for data science and the intersection of AI with medicine. He co-authored the eBook “Maximizing Productivity with ChatGPT.” As a 2022 Google Generation Scholar for APAC, she champions diversity and academic excellence. He has also been recognized as a Teradata Diversity in Tech Scholar, a MITACS GlobalLink Research Scholar, and a Harvard Wicked Scholar. Kanwal is a passionate advocate for change, having founded the Fame Code to empower women in stem fields.