Hi Bryan,
Yes I should have checked my data previously, im quite new to bokeh and pandas in general.
Here is the info of each dataframe before handing to the ColumnDataSource.
df:
RangeIndex: 14063 entries, 0 to 14062
Data columns (total 13 columns):
sid 14063 non-null int64
cid 14063 non-null int64
signature 14063 non-null int64
timestamp 14063 non-null datetime64[ns]
sig_id 14063 non-null int64
sig_name 14063 non-null object
sig_class_id 14063 non-null int64
sig_priority 14063 non-null int64
sig_rev 14063 non-null int64
sig_sid 14063 non-null int64
sig_gid 14063 non-null int64
sig_class_id 14063 non-null int64
sig_class_name 14063 non-null object
dtypes: datetime64ns, int64(10), object(2)
memory usage: 1.4+ MB
df2:
RangeIndex: 14066 entries, 0 to 14065
Data columns (total 2 columns):
ip_src 14066 non-null int64
ip_dst 14066 non-null int64
dtypes: int64(2)
memory usage: 219.9 KB
df3:
RangeIndex: 14070 entries, 0 to 14069
Data columns (total 2 columns):
tcp_sport 14070 non-null int64
tcp_dport 14070 non-null int64
dtypes: int64(2)
memory usage: 219.9 KB
df4:
RangeIndex: 14074 entries, 0 to 14073
Data columns (total 17 columns):
sid 14074 non-null int64
cid 14074 non-null int64
signature 14074 non-null int64
timestamp 14074 non-null datetime64[ns]
sig_id 14074 non-null int64
sig_name 14074 non-null object
sig_class_id 14074 non-null int64
sig_priority 14074 non-null int64
sig_rev 14074 non-null int64
sig_sid 14074 non-null int64
sig_gid 14074 non-null int64
sig_class_id 14074 non-null int64
sig_class_name 14074 non-null object
ip_src 14074 non-null int64
ip_dst 14074 non-null int64
tcp_sport 14074 non-null int64
tcp_dport 14074 non-null int64
dtypes: datetime64ns, int64(14), object(2)
memory usage: 1.8+ MB
Looking at this now makes me think there are several issues to contend with as the rows do not seem to match.
Thanks again,
Sean
···
On Wednesday, February 22, 2017 at 4:38:44 PM UTC, Bryan Van de ven wrote:
Well like I said I think think there is something unexpected about the structure of your particular data frame, though offhand I don’t know what. What is the output of df.info? E.g.
df.info()<class ‘pandas.core.frame.DataFrame’>
RangeIndex: 150 entries, 0 to 149
Data columns (total 5 columns):
sepal_length 150 non-null float64
sepal_width 150 non-null float64
petal_length 150 non-null float64
petal_width 150 non-null float64
species 150 non-null object
dtypes: float64(4), object(1)
memory usage: 5.9+ KB
Thanks,
Bryan
On Feb 22, 2017, at 10:25, MrShookshank [email protected] wrote:
Hi Bryan,
firstly sorry for the lack of information,
bokeh version = 0.12.4
pandas version = 0.19.2
My instinct was that the dataframe was somehow broken but unsure where.
My full code is;
from bokeh.plotting import ColumnDataSource
from sqlalchemy import create_engine
from config import *
import pandas as pd
engine = create_engine(mysql[‘connection’], pool_size=20, max_overflow=0)
df = pd.read_sql_query('SELECT * FROM event LEFT JOIN signature ON event.signature=signature.sig_id ’
'LEFT JOIN sig_class ON signature.sig_class_id=sig_class.sig_class_id;', engine).dropna()
df2 = pd.read_sql_query(‘SELECT ip_src,ip_dst FROM iphdr;’, engine)
df3 = pd.read_sql_query(‘SELECT tcp_sport, tcp_dport FROM tcphdr;’, engine)
df4 = pd.concat([df, df2, df3], axis=1)
source = ColumnDataSource(df4)
print(source)
I have also tried adding .values.tolist() to df4 which results in error: ValueError: expected an element of List(String), got seq with invalid items [0]
No pressure to spend to solving this for me, im just unsure whether its an issue in bokeh, pandas or just my own ignorance
Im not sure how I could provide data as its within a MySQL database with 10k rows.
Thanks,
Sean
On Wednesday, February 22, 2017 at 3:10:03 PM UTC, Bryan Van de ven wrote:
Please note: you have not specified the version of Bokeh, or the version of Pandas. It’s always advised to provide this kind of information when asking for help.
There is something unexpected or unusual about this DataFrame. You can look at the CDS code that coverts DataFames, it’s only a few lines of code:
[https://github.com/bokeh/bokeh/blob/master/bokeh/models/sources.py#L112-L133](https://github.com/bokeh/bokeh/blob/master/bokeh/models/sources.py#L112-L133)
As you can see, it calls .tolist on the columns of the DataFrame, which is normally fine. Is yours somehow nested? It’s really hard to say anything more specific unless you can provide code and data to reproduce the problem.
Thanks,
Bryan
On Feb 22, 2017, at 07:16, MrShookshank [email protected] wrote:
Hi fellow bokeh users,
I have the following code:
‘’’
from bokeh.plotting import ColumnDataSource
from sqlalchemy import create_engine
from config import *
import pandas as pd
engine = create_engine(mysql[‘connection’], pool_size=20, max_overflow=0)
df = pd.read_sql_query('SELECT * FROM event LEFT JOIN signature ON event.signature=signature.sig_id ’
‘LEFT JOIN sig_class ON signature.sig_class_id=sig_class.sig_class_id;’, engine)
source = ColumnDataSource(df)
print(source)
‘’’
the dataframe the query creates prints fine. However when I attempt to create the ColumnDataSource, i get this error;
“AttributeError: ‘DataFrame’ object has no attribute ‘tolist’”
Any help on this issue would be appreciated hugely.
Cheers.
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/001de17b-2115-487c-bbbf-d07f2029cde7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/f71272be-54ac-4fdc-99ca-0ffa46a257c7%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.