nicolaskruchten / jupyter_pivottablejs

Drag’n’drop Pivot Tables and Charts for Jupyter/IPython Notebook, care of PivotTable.js
http://nicolas.kruchten.com/content/2015/09/jupyter_pivottablejs/
Other
687 stars 88 forks source link

Sorters does not work #41

Closed kishmus closed 6 years ago

kishmus commented 6 years ago

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.

nicolaskruchten commented 6 years ago

Based on your usage of Python code I'm assuming you're using the Jupyter binding... It's not possible to use sorters with the Jupyter binding unfortunately: only JSON-serializable parameters can be used.

nicolaskruchten commented 6 years ago

(i've just updated the ReadMe here https://github.com/nicolaskruchten/jupyter_pivottablejs to make that clearer, sorry for any confusion!)

kishmus commented 6 years ago

Thanks Nicolas. Yes. I am using Jupyter binding.

AlexXQJ commented 4 years ago

Based on your usage of Python code I'm assuming you're using the Jupyter binding... It's not possible to use sorters with the Jupyter binding unfortunately: JSON-serializable parameters can be used.

Hi Nicolas, could you show me an example on this? i try:

sort_list='{"col_A": ["B","D","A","C"] }'
j = json.loads((sort_list))
pivot_ui(df,sorters=j)

but it comes out an error: An error occurred rendering the PivotTable UI.

emmm, any ideas? some examples would be better.

nicolaskruchten commented 4 years ago

Sorry, I've edited my reply to add the missing word "only": only JSON-serializable parameters can be used. Meaning functions simply cannot be passed through as they are not JSON-serializable.

AlexXQJ commented 4 years ago

Hi Nicols, thanks for your reply.