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

Feature Request: Support numpy.int64 in IPython notebook. #50

Closed
MGwynne opened this issue Apr 25, 2014 · 3 comments
Closed

Feature Request: Support numpy.int64 in IPython notebook. #50

MGwynne opened this issue Apr 25, 2014 · 3 comments
Assignees

Comments

@MGwynne
Copy link

MGwynne commented Apr 25, 2014

Currently, loading data from pandas DataFrames seems to be problematic as pandas uses numpy.int64 types, which apparently (?) aren't fully supported by python-nvd3 when displayed in IPython. It would be great if this was natively supported, so one could take data directly from the pandas DataFrame without converting back to long/int.

For example:

# This demo requires the installation of the python-nvd3 module.
# This can be downloaded from https://github.com/areski/python-nvd3 (the zip on the right)
# and installed via "pip install path_to_zip".
import random
from IPython import display as d
import nvd3
nvd3.ipynb.initialize_javascript(use_remote=True)

import numpy as np
import pandas as pd

df = pd.DataFrame({'x': range(nb_element), 'y': [i * random.randint(1, 10) for i in     range(nb_element)]})


chart3=nvd3.lineWithFocusChart(name="focusChart",height=450)
nb_element = 100
xdata = list(df['x'].values)
ydata = list(df['y'].values)
chart3.add_serie(x=xdata,y=ydata,name="random data")
chart3

yields "<nvd3.lineWithFocusChart.lineWithFocusChart instance at 0x0000000008BDE988>", while

# This demo requires the installation of the python-nvd3 module.
# This can be downloaded from https://github.com/areski/python-nvd3 (the zip on the right)
# and installed via "pip install path_to_zip".
import random
from IPython import display as d
import nvd3
nvd3.ipynb.initialize_javascript(use_remote=True)

import numpy as np
import pandas as pd

df = pd.DataFrame({'x': range(nb_element), 'y': [i * random.randint(1, 10) for i in     range(nb_element)]})


chart3=nvd3.lineWithFocusChart(name="focusChart",height=450)
nb_element = 100
xdata = list(long(x) for x in df['x'].values)
ydata = list(long(x) for x in df['y'].values)
chart3.add_serie(x=xdata,y=ydata,name="random data")
chart3

yields the correct graph displayed inline in IPython notebook.

@areski
Copy link
Owner

areski commented Apr 28, 2014

I suppose it's a matter of parsing the data properly in add_series
https://github.com/areski/python-nvd3/blob/master/nvd3/NVD3Chart.py#L175

I would appreciate if you can come up with a pull request to fix it and ensure it's backward compatible for peoples not using pandas.

@MGwynne
Copy link
Author

MGwynne commented Apr 30, 2014

I'll try to have a look at this this weekend.

@oz123 oz123 self-assigned this Aug 20, 2014
@areski
Copy link
Owner

areski commented Jan 4, 2016

closing for no activity

@areski areski closed this as completed Jan 4, 2016
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

3 participants