2

I am trying to reproduce the example of pivottable.js in jupyter notebook (here https://github.com/nicolaskruchten/jupyter_pivottablejs/tree/master/example) but I get an error :

Code (df is a pandas dataframe from a mps.csv in link above)

from pivottablejs import pivot_ui
pivot_ui(df,
   cols= ["Party"],
   rows= ["Province"],
   rendererName= "Horizontal Stacked Bar Chart",
   rowOrder= "value_z_to_a", 
   colOrder= "value_z_to_a",
   rendererOptions= {
       "c3": { "data": {"colors": {
           "Liberal": '#dc3912', "Conservative": '#3366cc', "NDP": '#ff9900',
           "Green":'#109618', 'Bloc Quebecois': '#990099'
       }}}
    }
)

Error

TypeError                                 Traceback (most recent call last)
<ipython-input-10-accb72869b19> in <module>()
 12         "c3": { "data": {"colors": {
 13             "Liberal": '#dc3912', "Conservative": '#3366cc', "NDP": '#ff9900',
---> 14             "Green":'#109618', 'Bloc Quebecois': '#990099'
 15         }}}
 16     }
TypeError: pivot_ui() got an unexpected keyword argument 'cols'

TypeError: pivot_ui() got an unexpected keyword argument 'cols'

I tried using 'columns' instead of 'cols' and it did not work.

Thanks for your help!

Here a screenshot of the jupyter notebook screenshot

Sandra
  • 23
  • 5
  • There seem to be a bug in what has been installed. I got the same error as you after installing the module via conda. Checking the source file the function pivot_ui seem to accept no keyword arguments. I created an issue on github and will get back here if I get an answer. – Karl Anka Jan 30 '18 at 10:09

1 Answers1

1

Apparently the name pivottablejs is overridden by some old version on conda and the original author is trying to solve this...

But it works if installing with pip instead.

So run conda remove pivottablejs and then pip install pivottablejs and it should work.

Karl Anka
  • 2,529
  • 1
  • 19
  • 30
  • (library author here) This is correct, and it's a real shame! Please vote on this issue to help build support for resolving the situation: https://github.com/ContinuumIO/pivottablejs-airgap/issues/3 – nicolaskruchten Feb 01 '18 at 03:32