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)
🐞 📊 Ladybug extension to generate 2D charts

ladybug-charts Ladybug extension to generate 2D charts. Installation pip install ladybug-charts QuickStart import ladybug_charts API Documentation Loc

Ladybug Tools 3 Dec 30, 2022
An(other) implementation of JSON Schema for Python

jsonschema jsonschema is an implementation of JSON Schema for Python. from jsonschema import validate # A sample schema, like what we'd get f

Julian Berman 4k Jan 04, 2023
visualize_ML is a python package made to visualize some of the steps involved while dealing with a Machine Learning problem

visualize_ML visualize_ML is a python package made to visualize some of the steps involved while dealing with a Machine Learning problem. It is build

Ayush Singh 164 Dec 12, 2022
The interactive graphing library for Python (includes Plotly Express) :sparkles:

plotly.py Latest Release User forum PyPI Downloads License Data Science Workspaces Our recommended IDE for Plotly’s Python graphing library is Dash En

Plotly 12.7k Jan 05, 2023
Sci palettes for matplotlib/seaborn

sci palettes for matplotlib/seaborn Installation python3 -m pip install sci-palettes Usage import seaborn as sns import matplotlib.pyplot as plt impor

Qingdong Su 2 Jun 07, 2022
Small binja plugin to import header file to types

binja-import-header (v1.0.0) Author: matteyeux Import header file to Binary Ninja types view Description: Binary Ninja plugin to import types from C h

matteyeux 15 Dec 10, 2022
A dashboard built using Plotly-Dash for interactive visualization of Dex-connected individuals across the country.

Dashboard For The DexConnect Platform of Dexterity Global Working prototype submission for internship at Dexterity Global Group. Dashboard for real ti

Yashasvi Misra 2 Jun 15, 2021
A simple python script using Numpy and Matplotlib library to plot a Mohr's Circle when given a two-dimensional state of stress.

Mohr's Circle Calculator This is a really small personal project done for Department of Civil Engineering, Delhi Technological University (formerly, D

Agyeya Mishra 0 Jul 17, 2021
Seismic Waveform Inversion Toolbox-1.0

Seismic Waveform Inversion Toolbox (SWIT-1.0)

Haipeng Li 98 Dec 29, 2022
Fast visualization of radar_scenes based on oleschum/radar_scenes

RadarScenes Tools About This python package provides fast visualization for the RadarScenes dataset. The Open GL based visualizer is smoother than ole

Henrik Söderlund 2 Dec 09, 2021
A concise grammar of interactive graphics, built on Vega.

Vega-Lite Vega-Lite provides a higher-level grammar for visual analysis that generates complete Vega specifications. You can find more details, docume

Vega 4k Jan 08, 2023
Gesture controlled media player

Media Player Gesture Control Gesture controller for media player with MediaPipe, VLC and OpenCV. Contents About Setup About A tool for using gestures

Atharva Joshi 2 Dec 22, 2021
Massively parallel self-organizing maps: accelerate training on multicore CPUs, GPUs, and clusters

Somoclu Somoclu is a massively parallel implementation of self-organizing maps. It exploits multicore CPUs, it is able to rely on MPI for distributing

Peter Wittek 239 Nov 10, 2022
Create animated and pretty Pandas Dataframe or Pandas Series

Rich DataFrame Create animated and pretty Pandas Dataframe or Pandas Series, as shown below: Installation pip install rich-dataframe Usage Minimal exa

Khuyen Tran 92 Dec 26, 2022
Fast 1D and 2D histogram functions in Python

About Sometimes you just want to compute simple 1D or 2D histograms with regular bins. Fast. No nonsense. Numpy's histogram functions are versatile, a

Thomas Robitaille 237 Dec 18, 2022
Example Code Notebooks for Data Visualization in Python

This repository contains sample code scripts for creating awesome data visualizations from scratch using different python libraries (such as matplotli

Javed Ali 27 Jan 04, 2023
An interactive GUI for WhiteboxTools in a Jupyter-based environment

whiteboxgui An interactive GUI for WhiteboxTools in a Jupyter-based environment GitHub repo: https://github.com/giswqs/whiteboxgui Documentation: http

Qiusheng Wu 105 Dec 15, 2022
2D maze path solver visualizer implemented with python

2D maze path solver visualizer implemented with python

SS 14 Dec 21, 2022
🎨 Python3 binding for `@AntV/G2Plot` Plotting Library .

PyG2Plot 🎨 Python3 binding for @AntV/G2Plot which an interactive and responsive charting library. Based on the grammar of graphics, you can easily ma

hustcc 990 Jan 05, 2023
simple tool to paint axis x and y

simple tool to paint axis x and y

G705 1 Oct 21, 2021