DEV Community

Bala Madhusoodhanan
Bala Madhusoodhanan

Posted on

PivotTable : Toolkit for Smart Data Exploration and Analysis

Pivot tables are a powerful JavaScript library that facilitates the creation of interactive pivot tables within web portals. These tables play a vital role in data analysis and exploration, providing an excellent tool for summarizing and navigating complex datasets during decision-making processes.

Package Installation

!pip install pivottablejs
Enter fullscreen mode Exit fullscreen mode

Importing Libraries:
Setting up the environment for the demo.

from pivottablejs import pivot_ui
import numpy as np
import pandas as pd
Enter fullscreen mode Exit fullscreen mode

Generating Synthetic Data:

num_rows = 10000
num_columns = 5
data = {
    'Cust_ID': np.arange(1, num_rows + 1),  # Unique identifier for each customer
    'Age': np.random.randint(18, 60, num_rows),  # Customer Age
    'Gender': np.random.choice(['Male', 'Female'], num_rows),  # Gender 
    'Affluency': np.random.choice(['Cluster A', 'Cluster B', 'Cluster C'], num_rows),  # Cluster group
    'Market_Follow_status': np.random.choice(['Ongoing', 'Completed'], num_rows)  # Follow-up status
df = pd.DataFrame(data)
Enter fullscreen mode Exit fullscreen mode

The Interactive Pivot Table Magic:
To generates an HTML page with an interactive pivot table UI for the DataFrame using this cool library. The HTML would be available in the working directory

Enter fullscreen mode Exit fullscreen mode

Users can explore and analyze the data by dragging and dropping columns into rows, columns, and values within the pivot table.

Demo 1

Demo 2

Github - Pivottable

Top comments (1)

wyattdave profile image
david wyatt

Very cool 😎