Hello,
I am new to Python, Bokeh and coding in general so please forgive me if I have done something dumb…
I have created a dataframe of zeroes using numpy and then I’m trying to pass it into a ColumnDataSource object for manipulation in Bokeh. The fact it is zeroes is not important; any time I try and do this using a dataframe created via a numpy array, I get the same error:
import pandas as pd
import numpy as np
from bokeh.models import ColumnDataSource
df = pd.DataFrame(np.zeros((8,8)))
source = ColumnDataSource(df)
The final line throws this error:
ValueError: expected an element of ColumnData(String, Seq(Any)), got {‘index’: array([0, 1, 2, 3… (it then prints out the entire dataframe)
df looks as expected:
0
1
2
3
4
5
6
7
0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
2
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
3
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
4
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
5
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
6
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
7
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
df.info() gives me this, which also seems in order:
<class ‘pandas.core.frame.DataFrame’>
RangeIndex: 8 entries, 0 to 7
Data columns (total 8 columns):
0 8 non-null float64
1 8 non-null float64
2 8 non-null float64
3 8 non-null float64
4 8 non-null float64
5 8 non-null float64
6 8 non-null float64
7 8 non-null float64
dtypes: float64(8)
memory usage: 592.0 bytes
I’m using:
Pandas version: 0.24.1
Bokeh version: 1.0.4
Numpy version: 1.16.1
Thanks,
Sam

