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
Importing Libraries:
Setting up the environment for the demo.
from pivottablejs import pivot_ui
import numpy as np
import pandas as pd
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)
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)
Users can explore and analyze the data by dragging and dropping columns into rows, columns, and values within the pivot table.
Top comments (1)
Very cool 😎