Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter notebook null values that dont exist in source pandas dataframe #52

Open
dominic2017 opened this issue Jul 11, 2019 · 9 comments

Comments

@dominic2017
Copy link

dominic2017 commented Jul 11, 2019

Hi, i used pip install and had this same null error.

aas

What is the solution?

packages under my pip list:
absl-py 0.7.1
altair 3.1.0
astor 0.8.0
attrs 19.1.0
backcall 0.1.0
bleach 3.1.0
bokeh 1.2.0
boto 2.48.0
certifi 2019.6.16
chardet 3.0.4
Click 7.0
colorama 0.4.1
cycler 0.10.0
decorator 4.4.0
defusedxml 0.6.0
entrypoints 0.3
Flask 1.1.0
gast 0.2.2
grpcio 1.21.1
h5py 2.9.0
idna 2.7
imageio 2.5.0
ipykernel 5.1.1
ipython 7.5.0
ipython-genutils 0.2.0
ipywidgets 7.4.2
itsdangerous 1.1.0
jedi 0.13.3
Jinja2 2.10.1
jsonschema 3.0.1
jupyter 1.0.0
jupyter-client 5.2.4
jupyter-console 6.0.0
jupyter-contrib-core 0.3.3
jupyter-contrib-nbextensions 0.5.1
jupyter-core 4.4.0
jupyter-highlight-selected-word 0.2.0
jupyter-latex-envs 1.4.6
jupyter-nbextensions-configurator 0.4.1
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
kiwisolver 1.1.0
lime 0.1.1.29
lxml 4.3.3
Markdown 3.1.1
MarkupSafe 1.1.1
matplotlib 2.2.2
mistune 0.8.4
nbconvert 5.5.0
nbformat 4.4.0
networkx 2.3
notebook 5.7.8
numpy 1.14.3
packaging 19.0
pandas 0.24.1
pandocfilters 1.4.2
parso 0.4.0
pickleshare 0.7.5
Pillow 6.0.0
pip 19.1.1
pivottablejs 0.9.0
prometheus-client 0.6.0
prompt-toolkit 2.0.9
protobuf 3.8.0
Pygments 2.4.2
pynegv 0.45.5
pyodbc 4.0.24
pyparsing 2.4.0
pypiwin32 223
pyrsistent 0.15.2
python-certifi-win32 1.2
python-dateutil 2.7.3
pytz 2019.1
PyWavelets 1.0.3
pywin32 224
pywinpty 0.5.5
PyYAML 5.1
pyzmq 18.0.1
qgrid 1.1.1
qtconsole 4.5.1
requests 2.19.1
requests-negotiate-sspi 0.5.2
scikit-image 0.15.0
scikit-learn 0.20.2
scipy 1.1.0
seaborn 0.9.0
Send2Trash 1.5.0
setuptools 28.8.0
six 1.12.0
tensorboard 1.12.2
tensorflow 1.12.0
termcolor 1.1.0
terminado 0.8.2
testpath 0.4.2
toolz 0.9.0
tornado 6.0.2
traitlets 4.3.2
urllib3 1.22
vega 2.3.2
vega-datasets 0.7.0
virtualenv 16.6.0
virtualenvwrapper-win 1.2.5
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.15.4
wheel 0.33.4
widgetsnbextension 3.4.2
wincertstore 0.2
wrapt 1.11.2
xlrd 1.2.0
XlsxWriter 1.1.8

@dominic2017
Copy link
Author

Hi, i cant seem to solve this after a week. Any suggestions?

@nicolaskruchten
Copy link
Owner

Can you provide a sample dataset that causes this issue?

@dominic2017
Copy link
Author

dominic2017 commented Jul 16, 2019

@ghost
Copy link

ghost commented Sep 5, 2019

Hi frankquekch,
What is your OS? If you are using Windows, try the following workaround:

import pandas as pd
df = pd.DataFrame([['a', 'aaa'], ['b', 'bbb']], columns=['var1', 'var2'])
df

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)

pivot_ui(df)

Hope it help.

@karenbold
Copy link

thanks looks good!

@karenbold
Copy link

Hi I wondered is there a way to add the % value labels for series onto the charts if doing % of row or columns?

@stefaneidelloth
Copy link

stefaneidelloth commented Sep 22, 2020

I also saw the null values on windows and the workaround of overriding the pivot_ui method worked for me.
Could you please detect the OS and fix the line endings automatically in the code?

@bogus-accnt
Copy link

Still not solved, but workaround works!

@sdementen
Copy link

The pivot_ui function should be adapted to specify newline="\n" (instead of using the default "\r\n" on windows)

def pivot_ui(df, outfile_path = "pivottablejs.html", url="",
    width="100%", height="500", **kwargs):
    with io.open(outfile_path, 'wt', newline="\n", encoding='utf8') as outfile:
        csv = df.to_csv(encoding='utf8')
        if hasattr(csv, 'decode'):
            csv = csv.decode('utf8')
        outfile.write(TEMPLATE %
            dict(csv=csv, kwargs=json.dumps(kwargs)))
    return IFrame(src=url or outfile_path, width=width, height=height)

sdementen added a commit to sdementen/jupyter_pivottablejs that referenced this issue Mar 15, 2024
specify a newline="\n" to ensure that on windows the csv has not "\r\n" as otherwise pivottable will see rows with null values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants