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)
Automatic data visualization in atom with the nteract data-explorer

Data Explorer Interactively explore your data directly in atom with hydrogen! The nteract data-explorer provides automatic data visualization, so you

Ben Russert 65 Dec 01, 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
JSNAPY example: Validate NAT policies

JSNAPY example: Validate NAT policies Overview This example will show how to use JSNAPy to make sure the expected NAT policy matches are taking place.

Calvin Remsburg 1 Jan 07, 2022
Implementation of SOMs (Self-Organizing Maps) with neighborhood-based map topologies.

py-self-organizing-maps Simple implementation of self-organizing maps (SOMs) A SOM is an unsupervised method for learning a mapping from a discrete ne

Jonas Grebe 6 Nov 22, 2022
Python wrapper for Synoptic Data API. Retrieve data from thousands of mesonet stations and networks. Returns JSON from Synoptic as Pandas DataFrame

☁ Synoptic API for Python (unofficial) The Synoptic Mesonet API (formerly MesoWest) gives you access to real-time and historical surface-based weather

Brian Blaylock 23 Jan 06, 2023
By default, networkx has problems with drawing self-loops in graphs.

By default, networkx has problems with drawing self-loops in graphs. It makes it hard to draw a graph with self-loops or to make a nicely looking chord diagram. This repository provides some code to

Vladimir Shitov 5 Jan 06, 2022
a plottling library for python, based on D3

Hello August 2013 Hello! Maybe you're looking for a nice Python interface to build interactive, javascript based plots that look as nice as all those

Mike Dewar 1.4k Dec 28, 2022
Data Visualizer for Super Mario Kart (SNES)

Data Visualizer for Super Mario Kart (SNES)

MrL314 21 Nov 20, 2022
This is a learning tool and exploration app made using the Dash interactive Python framework developed by Plotly

Support Vector Machine (SVM) Explorer This app has been moved here. This repo is likely outdated and will not be updated. This is a learning tool and

Plotly 150 Nov 03, 2022
Arras.io Highest Scores Over Time Bar Chart Race

Arras.io Highest Scores Over Time Bar Chart Race This repo contains a python script (make_racing_bar_chart.py) that can generate a csv file which can

Road 2 Jan 16, 2022
Minimal Ethereum fee data viewer for the terminal, contained in a single python script.

Minimal Ethereum fee data viewer for the terminal, contained in a single python script. Connects to your node and displays some metrics in real-time.

48 Dec 05, 2022
Turn a STAC catalog into a dask-based xarray

StackSTAC Turn a list of STAC items into a 4D xarray DataArray (dims: time, band, y, x), including reprojection to a common grid. The array is a lazy

Gabe Joseph 148 Dec 19, 2022
A data visualization curriculum of interactive notebooks.

A data visualization curriculum of interactive notebooks, using Vega-Lite and Altair. This repository contains a series of Python-based Jupyter notebooks.

UW Interactive Data Lab 1.2k Dec 30, 2022
Python Data. Leaflet.js Maps.

folium Python Data, Leaflet.js Maps folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js

6k Jan 02, 2023
Graphical display tools, to help students debug their class implementations in the Carcassonne family of projects

carcassonne_tools Graphical display tools, to help students debug their class implementations in the Carcassonne family of projects NOTE NOTE NOTE The

1 Nov 08, 2021
Manim is an animation engine for explanatory math videos.

A community-maintained Python framework for creating mathematical animations.

12.4k Dec 30, 2022
plotly scatterplots which show molecule images on hover!

molplotly Plotly scatterplots which show molecule images on hovering over the datapoints! Required packages: pandas rdkit jupyter_dash ➡️ See example.

150 Dec 28, 2022
Generate knowledge graphs with interesting geometries, like lattices

Geometric Graphs Generate knowledge graphs with interesting geometries, like lattices. Works on Python 3.9+ because it uses cool new features. Get out

Charles Tapley Hoyt 5 Jan 03, 2022
Make your BSC transaction simple.

bsc_trade_history Make your BSC transaction simple. 中文ReadMe Background: inspired by debank ,Practice my hands on this small project Blog:Crypto-BscTr

foolisheddy 7 Jul 06, 2022
An interactive dashboard built with python that enables you to visualise how rent prices differ across Sweden.

sweden-rent-dashboard An interactive dashboard built with python that enables you to visualise how rent prices differ across Sweden. The dashboard/web

Rory Crean 5 Dec 19, 2021