from __future__ import absolute_import, division, print_function

from ..convert import convert
import pandas as pd
try:
    from bokeh.models import ColumnDataSource
except ImportError:
    ColumnDataSource = type(None)

@convert.register(pd.DataFrame, ColumnDataSource)
def columndatasource_to_dataframe(cds, **kwargs):
    df = cds.to_df()
    return df[sorted(df.columns)]


@convert.register(ColumnDataSource, pd.DataFrame)
def dataframe_to_columndatasource(df, **kwargs):
    d = ColumnDataSource.from_df(df)
    if 'index' in d:
        d.pop('index')
    return ColumnDataSource(d)

@@ -59,16 +59,37 @@
 nction%0A%0A
+import pandas as pd%0A%0A
 from ..c
@@ -114,134 +114,119 @@
 ert%0A
-import pandas as pd%0Atry:%0A    from bokeh.models import ColumnDataSource%0Aexcept ImportError:%0A    ColumnDataSource = type(None)%0A%0A
+from ..utils import ignoring%0A%0A%0Awith ignoring(ImportError):%0A    from bokeh.models import ColumnDataSource%0A%0A%0A    
 @con
@@ -271,16 +271,20 @@
 Source)%0A
+    
 def colu
@@ -329,16 +329,20 @@
 s):%0A    
+  
+  
 df = cds
@@ -350,16 +350,20 @@
 to_df()%0A
+    
     retu
@@ -390,16 +390,20 @@
 mns)%5D%0A%0A%0A
+    
 @convert
@@ -444,16 +444,20 @@
 aFrame)%0A
+    
 def data
@@ -493,24 +493,28 @@
  **kwargs):%0A
+    
     d = Colu
@@ -542,16 +542,20 @@
 df)%0A    
+  
+  
 if 'inde
@@ -571,16 +571,20 @@
         
+    
 d.pop('i
@@ -590,16 +590,20 @@
 index')%0A
+    
     retu

Remove nonetype edges from bokeh module when not installed.