2

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.

pivottable.js image

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!

Community
  • 1
  • 1
  • Hi, I'm the author of this library... Can you file a Github issue here please? https://github.com/nicolaskruchten/jupyter_pivottablejs/issues – nicolaskruchten Feb 01 '19 at 19:12
  • I'm not able to replicate this locally, so I'll need more info about your system, but it's much easier to communicate via Github :) – nicolaskruchten Feb 01 '19 at 19:18
  • Nicolas, thanks for your response! I filed a Github issue as you suggested. Did my usage of pivottablejs look correct? Thanks! – nick_montpetit Feb 01 '19 at 23:18
  • Also, is there an alternative data representation I can use as input that's not a pandas dataframe? I couldn't tell from the jupyter_pivottablejs documentation. Happy to plug in some other data representation if that avoids this issue. – nick_montpetit Feb 01 '19 at 23:22

1 Answers1

0

The issue is not yet solved in the code for Windows.

Here is the corresponding Github issue: https://github.com/nicolaskruchten/jupyter_pivottablejs/issues/52

They provide a work around that worked for me:

def pivot_ui(df, **kwargs):
    import pivottablejs
    class _DataFrame(pd.DataFrame):
        def to_csv(self, **kwargs):
            return super().to_csv(**kwargs).replace("\r\n", "\n")
    return pivottablejs.pivot_ui(_DataFrame(df), **kwargs)
Stefan
  • 10,010
  • 7
  • 61
  • 117