Drag’n’drop Pivot Tables and Charts for Jupyter/IPython Notebook, care of PivotTable.js

Overview

pivottablejs: the Python module

Drag’n’drop Pivot Tables and Charts for Jupyter/IPython Notebook, care of PivotTable.js

Installation

pip install pivottablejs or conda install pivottablejs

Note in the past, the conda command above installed pivottablejs-airgap instead of this library; apologies for any confusion this change may cause.

Usage

import pandas as pd
df = pd.read_csv("some_input.csv")

from pivottablejs import pivot_ui

pivot_ui(df)

Advanced Usage

Include any JSON-serializable option to PivotTable.js's pivotUI() function as a keyword argument.

pivot_ui(df, rows=['row_name'], cols=['col_name'])

Independently control the output file path and the URL used to access it from Jupyter, in case the default relative-URL behaviour is incompatible with Jupyter's settings.

pivot_ui(df, outfile_path="/x/y.html", url="http://localhost/a/b/x.html")
Comments
  • Not working in jupyter within VMware vm

    Not working in jupyter within VMware vm

    Hiya Nicolas,

    I'm finding that jupyter launches pivots on my laptop just fine, but am having issues at work. [On the latter, I'm behind a firewall and also running on a vmware instance in stand-alone/non-bridged mode. The proxy settings seem to be fine otherwise, and I even set HTTP_PROXY and HTTPS_PROXY environment vars for anaconda to pickup automatically as well as setting ssl_verify to False.] The pandas dataframes load just fine, but I'm not seeing anything in the cell where I try to display a pivot_ui using even the simple examples that you've provided.

    I've even started jupyter with --debug and looked at the logs, but don't see what's going on yet. Any suggestions for how to debug this?

    Much obliged for your indulgence on this, and all your fine efforts. Rick

    p.s. Saw your note elsewhere on the output path issues. When I set the output file path to an absolute location (e.g. "/blah/bleh/test.html") I did get a 404, but when I just specified a relative path ("test.html") it failed silently again (but wrote "test.html"). Also, I do not see the "pop out" text within the output cell.... it's perfectly blank....

    p.p.s. I'm also trying to get Chrome installed on Redhat to use the Javascipt debugging extensions to better isolate the issue, but haven't been successful there either yet.

    opened by rickFanta 18
  • UnicodeEncodeError when trying pivot_ui(df)

    UnicodeEncodeError when trying pivot_ui(df)

    Great tool for data exploration, I think this should be a core utility of Jupyter!

    I got the error message: UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-11: ordinal not in range(128)

    I think it is because of of the pd.to_csv method, adding some encoding handling capability could fix this.

    But not really sure how...

    thank you for the great js magic!

    opened by Paul-Yuchao-Dong 17
  • Pivottable as an IPyWidget?

    Pivottable as an IPyWidget?

    I'm not sure how this would work, but I wonder if as well as using the pivot table to explore and interact with data from a pandas dataframe, it might be useful to provide a mechanism for passing the data back from the pivottable to a pandas dataframe using an IPyWidget mechanic? (Some related ideas in the context of dashboards here.)

    For teaching purposes, it might also be handy to provide a view of pandas code that mimics any operations performed in the pivottable? (If there was no return path of data from the widget back to pandas, at least the user could copy the generated code and apply it to the original dataframe using pandas?

    opened by psychemedia 16
  • Page Not Found

    Page Not Found

    Love this idea...but can't quite get it to work. I am relatively new to python, so I am assuming I am missing a setting, version conflict, or maybe a firewall issue (or something similar). I keep getting an error: 404 : Not Found You are requesting a page that does not exist!

    in my ipython notebook. I don't see anything on github to explain this, but have a feeling it is something simple. Any help would be greatly appreciated! Thanks. pivottablejs_error

    opened by Joehurley 10
  • pivottable.js display introduces NULL values that don't exist in the source pandas Dataframe

    pivottable.js display introduces NULL values that don't exist in the source pandas Dataframe

    I believe I'm using pivottable.js (in a Jupyter notebook) correctly, but please let me know if that's not the case.

    In this example, I'm creating almost the simplest pandas dataframe possible:

    test_data = DataFrame([['a', 'b'], ['b', 'a']], columns=['var1', 'var2'])
    
    test_data
    

    Dataframe:

     	var1 var2
    0 	  a 	b
    1 	  b 	a
    

    When I display this in pivottable.js

    pivot_ui(test_data)
    

    The table shows that var1 and var2 both have 3 NULL values, and a total count of 5 records.

    https://i.stack.imgur.com/M9y4Q.jpg

    Is this expected behavior for my usage shown above? More than happy to be told I'm an idiot and I'm using pivottable.js incorrectly. :)

    If this is unexpected behavior, I can provide further information about my system configuration.

    Thanks!

    opened by nmontpetit 9
  • Sorters does not work

    Sorters does not work

    Hi, I am trying to use sorters with pivot_ui. I get the following error in the browser "An error occurred rendering the PivotTable UI."

    Code as below: import pandas as pd import numpy as np import pivottablejs as pj

    linDir = "F:\Operations\MIS\DailyLockedIn\" linFile = "LockedInDataSheet.xlsx" outHtml = linDir+"LI.html"

    ld = pd.read_excel(linDir+linFile) pj.pivot_ui(ld, outfile_path=outHtml, rows=["IPG"], cols=["LOAD_DATE","Parameter"], aggregatorName="Integer Sum", vals=["AP"], exclusions={"IPG":["NO IPG","PES-IND"], "Parameter":["ELAPSED","@ RISK EBD"]}, sorters={"Parameter":["BHC","ERD","EBD","ELAPSED","@ RISK EBD"]} sort_keys = True )

    Any help is highly appreciated.

    opened by kishmus 6
  • Apply filter by defaul

    Apply filter by defaul

    Is there any way to apply the 'filter' from PivotTableJs directly on Python, eg, have a bunch of data but by default apply a filter to it, so that all data is available but only some is on display by default?

    opened by jorgelaranjo 5
  • How to create a save/restore config through cookie in python code

    How to create a save/restore config through cookie in python code

    Hi. I read through your examples: onRefresh example and save_restore example

    but I am unable to figure out how to create that javascript code through the pivot_ui() function call in Jupyter notebook. I realize that pivot_ui(data, onRefresh="something") can be used but in javascript onRefresh should be assigned a callback function and as far as I could experiment, the "something" always gets passed in as string.

    opened by mbkamble 5
  • Hide Totals column/row?

    Hide Totals column/row?

    Hi

    https://github.com/nicolaskruchten/pivottable/wiki/Frequently-Asked-Questions#totals

    I'd like to be able to hide the totals column/row using this python module and as answered in the link above. How would one go about doing this?

    opened by tomioueda 5
  • There is no option to control the type of graphs that can be generated for the data

    There is no option to control the type of graphs that can be generated for the data

    User cannot choose the type of graphs that needs to be generated. Say, only bar graphs and tree map is needed, the user cannot choose and still has to display all other options even though not used.

    opened by vishnuragas 4
  • Pivottable.js Installation

    Pivottable.js Installation

    Can you please provide a visual installation of pivottable? I am not very familiar with the coding. I would like to install it on Easyphp server on my computer. I went through your documentation, and made some internet search but I couldn't find visual installation guides. Thanks.

    opened by Mattin30 4
  • newbie entire table not display, can not screen capture, booleans not working

    newbie entire table not display, can not screen capture, booleans not working

    fantastic tool.

    I use it from a python Jupiter lab notebook. I have run into a couple of problems

    if I construct the table interactively it creates a nice table. however the entire table is not displayed. I have to scroll. This prevents me from using screen capture.

    Also is there a way to extract whatever argument (row, cols, ...) I would need if I wanted to recreate the table programmatically. It seems like I am constantly re-doing my plot

    Kind regards

    Andy

    opened by aedavids 0
  • ImportError: cannot import name 'pivot_ui' from partially initialized module 'pivottablejs' (most likely due to a circular import)

    ImportError: cannot import name 'pivot_ui' from partially initialized module 'pivottablejs' (most likely due to a circular import)

    'import streamlit as st import streamlit.components.v1 as components from pivottablejs import pivot_ui import pandas as pd

    iris = pd.read_csv( "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv" )

    t = pivot_ui(iris)

    with open(t.src) as t: components.html(t.read(), width=900, height=1000, scrolling=True)`

    When trying this example I get this error : ImportError: cannot import name 'pivot_ui' from partially initialized module 'pivottablejs' (most likely due to a circular import) I tested it without streamlit and resulted in the save error : I tested in .py file and jupyter notebook Thanks for an answer

    opened by TONODEKEN 0
  • Changing the table orientation like pivotablejs in jupyter_pivottablejs

    Changing the table orientation like pivotablejs in jupyter_pivottablejs

    Hi, Thanks a lot for this amazing tool with python support.

    So far this is the only one that can generate offline HTML with dataframe tables and plot.

    This interactive offline html versionjs table looks like this image with the columns values in the far left horizontal box and the plot dropdown on top of that. This needs dragging of each column to the second horizontal box to visualize the column contents or the plots.

    Just wondering if it is possible to align them like the one in the regular pivotblejs. This one very convinient.

    image

    opened by gopi1616 0
  • No display in jupyter notebook

    No display in jupyter notebook

    Someone else posted this before but in a hijacking attempt of another issue, so let me repeat it here:

    pivot_ui(df) does not display anything for some users (including me).

    See this screenshot from the other issue as well as yet another issue, which I think describes the same problem but isn't very specific about it.

    opened by soerenwolfers 1
  • Plotly support (Python)

    Plotly support (Python)

    I'm using pivottables.js in a Jupyter Notebook, and would like to know if it is possible to use the Plotly renderer the same way it is used in the JavaScript implementation? It would be very useful, especially the ability to save charts generated to a file.

    If there is no support for Plotly, is there any other way I could save the charts to files on my computer?

    Thanks!

    opened by arielhara1 0
Releases(v0.9.0)
Python package for hypergraph analysis and visualization.

The HyperNetX library provides classes and methods for the analysis and visualization of complex network data. HyperNetX uses data structures designed to represent set systems containing nested data

Pacific Northwest National Laboratory 304 Dec 27, 2022
Create a table with row explanations, column headers, using matplotlib

Create a table with row explanations, column headers, using matplotlib. Intended usage was a small table containing a custom heatmap.

4 Aug 14, 2022
Seismic Waveform Inversion Toolbox-1.0

Seismic Waveform Inversion Toolbox (SWIT-1.0)

Haipeng Li 98 Dec 29, 2022
In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas

CogniPy for Pandas - In-memory Graph Database and Knowledge Graph with Natural Language Interface Whats in the box Reasoning, exploration of RDF/OWL,

Cognitum Octopus 34 Dec 13, 2022
TensorDebugger (TDB) is a visual debugger for deep learning. It extends TensorFlow with breakpoints + real-time visualization of the data flowing through the computational graph

TensorDebugger (TDB) is a visual debugger for deep learning. It extends TensorFlow (Google's Deep Learning framework) with breakpoints + real-time visualization of the data flowing through the comput

Eric Jang 1.4k Dec 15, 2022
Simple and fast histogramming in Python accelerated with OpenMP.

pygram11 Simple and fast histogramming in Python accelerated with OpenMP with help from pybind11. pygram11 provides functions for very fast histogram

Doug Davis 28 Dec 14, 2022
web application for flight log analysis & review

Flight Review This is a web application for flight log analysis. It allows users to upload ULog flight logs, and analyze them through the browser. It

PX4 Drone Autopilot 145 Dec 20, 2022
Eulera Dashboard is an easy and intuitive way to get a quick feel of what’s happening on the world’s market.

an easy and intuitive way to get a quick feel of what’s happening on the world’s market ! Eulera dashboard is a tool allows you to monitor historical

Salah Eddine LABIAD 4 Nov 25, 2022
Draw tree diagrams from indented text input

Draw tree diagrams This repository contains two very different scripts to produce hierarchical tree diagrams like this one: $ ./classtree.py collectio

Luciano Ramalho 8 Dec 14, 2022
Frbmclust - Clusterize FRB profiles using hierarchical clustering, plot corresponding parameters distributions

frbmclust Getting Started Clusterize FRB profiles using hierarchical clustering,

3 May 06, 2022
Plot toolbox based on Matplotlib, simple and elegant.

Elegant-Plot Plot toolbox based on Matplotlib, simple and elegant. 绘制效果 绘制过程 数据准备 每种图标类型的目录下有data.csv文件,依据样例数据填入自己的数据。

3 Jul 15, 2022
HW 02 for CS40 - matplotlib practice

HW 02 for CS40 - matplotlib practice project instructions https://github.com/mikeizbicki/cmc-csci040/tree/2021fall/hw_02 Drake Lyric Analysis Bar Char

13 Oct 27, 2021
FairLens is an open source Python library for automatically discovering bias and measuring fairness in data

FairLens FairLens is an open source Python library for automatically discovering bias and measuring fairness in data. The package can be used to quick

Synthesized 69 Dec 15, 2022
Minimalistic tool to visualize how the routes to a given target domain change over time, feat. Python 3.10 & mermaid.js

Minimalistic tool to visualize how the routes to a given target domain change over time, feat. Python 3.10 & mermaid.js

Péter Ferenc Gyarmati 1 Jan 17, 2022
Create Badges with stats of Scratch User, Project and Studio. Use those badges in Github readmes, etc.

Scratch-Stats-Badge Create customized Badges with stats of Scratch User, Studio or Project. Use those badges in Github readmes, etc. Examples Document

Siddhesh Chavan 5 Aug 28, 2022
A napari plugin for visualising and interacting with electron cryotomograms.

napari-tomoslice A napari plugin for visualising and interacting with electron cryotomograms. Installation You can install napari-tomoslice via pip: p

3 Jan 03, 2023
A research of IT labor market based especially on hh.ru. Salaries, rate of technologies and etc.

hh_ru_research Проект реализован в учебных целях анализа рынка труда, в особенности по hh.ru Input data В качестве входных данных используются сериали

3 Sep 07, 2022
Set of matplotlib operations that are not trivial

Matplotlib Snippets This repository contains a set of matplotlib operations that are not trivial. Histograms Histogram with bins adapted to log scale

Raphael Meudec 1 Nov 15, 2021
Flexitext is a Python library that makes it easier to draw text with multiple styles in Matplotlib

Flexitext is a Python library that makes it easier to draw text with multiple styles in Matplotlib

Tomás Capretto 93 Dec 28, 2022
Python histogram library - histograms as updateable, fully semantic objects with visualization tools. [P]ython [HYST]ograms.

physt P(i/y)thon h(i/y)stograms. Inspired (and based on) numpy.histogram, but designed for humans(TM) on steroids(TM). The goal is to unify different

Jan Pipek 120 Dec 08, 2022