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)
Dipto Chakrabarty 7 Sep 06, 2022
simple tool to paint axis x and y

simple tool to paint axis x and y

G705 1 Oct 21, 2021
Simple implementation of Self Organizing Maps (SOMs) with rectangular and hexagonal grid topologies

py-self-organizing-map Simple implementation of Self Organizing Maps (SOMs) with rectangular and hexagonal grid topologies. A SOM is a simple unsuperv

Jonas Grebe 1 Feb 10, 2022
Comparing USD and GBP Exchange Rates

Currency Data Visualization Comparing USD and GBP Exchange Rates This is a bar graph comparing GBP and USD exchange rates. I chose blue for the UK bec

5 Oct 28, 2021
Python package for the analysis and visualisation of finite-difference fields.

discretisedfield Marijan Beg1,2, Martin Lang2, Samuel Holt3, Ryan A. Pepper4, Hans Fangohr2,5,6 1 Department of Earth Science and Engineering, Imperia

ubermag 12 Dec 14, 2022
Learn Basic to advanced level Data visualisation techniques from this Repository

Data visualisation Hey, You can learn Basic to advanced level Data visualisation techniques from this Repository. Data visualization is the graphic re

Shashank dwivedi 16 Jan 03, 2023
High-level geospatial data visualization library for Python.

geoplot: geospatial data visualization geoplot is a high-level Python geospatial plotting library. It's an extension to cartopy and matplotlib which m

Aleksey Bilogur 1k Jan 01, 2023
Visualize the bitcoin blockchain from your local node

Project Overview A new feature in Bitcoin Core 0.20 allows users to dump the state of the blockchain (the UTXO set) using the command dumptxoutset. I'

18 Sep 11, 2022
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
Numerical methods for ordinary differential equations: Euler, Improved Euler, Runge-Kutta.

Numerical methods Numerical methods for ordinary differential equations are methods used to find numerical approximations to the solutions of ordinary

Aleksey Korshuk 5 Apr 29, 2022
A script written in Python that generate output custom color (HEX or RGB input to x1b hexadecimal)

ColorShell ─ 1.5 Planned for v2: setup.sh for setup alias This script converts HEX and RGB code to x1b x1b is code for colorize outputs, works on ou

Riley 4 Oct 31, 2021
Interactive chemical viewer for 2D structures of small molecules

👀 mols2grid mols2grid is an interactive chemical viewer for 2D structures of small molecules, based on RDKit. ➡️ Try the demo notebook on Google Cola

Cédric Bouysset 154 Dec 26, 2022
Moscow DEG 2021 elections plots

Построение графиков на основе публичных данных о ДЭГ в Москве в 2021г. Описание Скрипты в данном репозитории позволяют собственноручно построить графи

9 Jul 15, 2022
ecoglib: visualization and statistics for high density microecog signals

ecoglib: visualization and statistics for high density microecog signals This library contains high-level analysis tools for "topos" and "chronos" asp

1 Nov 17, 2021
Visualize large time-series data in plotly

plotly_resampler enables visualizing large sequential data by adding resampling functionality to Plotly figures. In this Plotly-Resampler demo over 11

PreDiCT.IDLab 604 Dec 28, 2022
These data visualizations were created for my introductory computer science course using Python

Homework 2: Matplotlib and Data Visualization Overview These data visualizations were created for my introductory computer science course using Python

Sophia Huang 12 Oct 20, 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
Scientific Visualization: Python + Matplotlib

An open access book on scientific visualization using python and matplotlib

Nicolas P. Rougier 8.6k Dec 31, 2022
Epagneul is a tool to visualize and investigate windows event logs

epagneul Epagneul is a tool to visualize and investigate windows event logs. Dep

jurelou 190 Dec 13, 2022
Data-FX is an addon for Blender (2.9) that allows for the visualization of data with different charts

Data-FX Data-FX is an addon for Blender (2.9) that allows for the visualization of data with different charts Currently, there are only 2 chart option

Landon Ferguson 20 Nov 21, 2022