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)
IPython/Jupyter notebook module for Vega and Vega-Lite

IPython Vega IPython/Jupyter notebook module for Vega 5, and Vega-Lite 4. Notebooks with embedded visualizations can be viewed on GitHub and nbviewer.

Vega 335 Nov 29, 2022
IPython/Jupyter notebook module for Vega and Vega-Lite

IPython Vega IPython/Jupyter notebook module for Vega 5, and Vega-Lite 4. Notebooks with embedded visualizations can be viewed on GitHub and nbviewer.

Vega 294 Feb 12, 2021
`charts.css.py` brings `charts.css` to Python. Online documentation and samples is available at the link below.

charts.css.py charts.css.py provides a python API to convert your 2-dimension data lists into html snippet, which will be rendered into charts by CSS,

Ray Luo 3 Sep 23, 2021
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 29, 2022
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 30, 2022
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3k Feb 18, 2021
Streaming pivot visualization via WebAssembly

Perspective is an interactive visualization component for large, real-time datasets. Originally developed for J.P. Morgan's trading business, Perspect

The Fintech Open Source Foundation (www.finos.org) 5.1k Dec 27, 2022
Streaming pivot visualization via WebAssembly

Perspective is an interactive visualization component for large, real-time datasets. Originally developed for J.P. Morgan's trading business, Perspect

The Fintech Open Source Foundation (www.finos.org) 3.2k Feb 18, 2021
Render Jupyter notebook in the terminal

jut - JUpyter notebook Terminal viewer. The command line tool view the IPython/Jupyter notebook in the terminal. Install pip install jut Usage $jut --

Kracekumar 169 Dec 27, 2022
Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python 564 Jan 3, 2023
ipyvizzu - Jupyter notebook integration of Vizzu

ipyvizzu - Jupyter notebook integration of Vizzu. Tutorial · Examples · Repository About The Project ipyvizzu is the Jupyter Notebook integration of V

Vizzu 729 Jan 8, 2023
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

D3xter 31 Mar 6, 2021
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 3.2k Jan 4, 2023
🧇 Make Waffle Charts in Python.

PyWaffle PyWaffle is an open source, MIT-licensed Python package for plotting waffle charts. It provides a Figure constructor class Waffle, which coul

Guangyang Li 528 Jan 2, 2023
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 2.8k Feb 18, 2021
🧇 Make Waffle Charts in Python.

PyWaffle PyWaffle is an open source, MIT-licensed Python package for plotting waffle charts. It provides a Figure constructor class Waffle, which coul

Guangyang Li 397 Feb 17, 2021
Streamlit dashboard examples - Twitter cashtags, StockTwits, WSB, Charts, SQL Pattern Scanner

streamlit-dashboards Streamlit dashboard examples - Twitter cashtags, StockTwits, WSB, Charts, SQL Pattern Scanner Tutorial Video https://ww

null 122 Dec 21, 2022
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 3.2k Jan 1, 2023
mysql relation charts

sqlcharts 自动生成数据库关联关系图 复制settings.py.example 重命名为settings.py 将数据库配置信息填入settings.DATABASE,目前支持mysql和postgresql 执行 python build.py -b,-b是读取数据库表结构,如果只更新匹

null 6 Aug 22, 2022