PivotTable : Toolkit for Smart Data Exploration and Analysis

Bala Madhusoodhanan - Mar 13 - - Dev Community

Introduction:
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:

np.random.seed(10)
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

pivot_ui(df)
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

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .