Learn Before
Code

Converting a Pandas DataFrame to a Bokeh ColumnDataSource

To convert a Pandas DataFrame into a Bokeh ColumnDataSource, pass the DataFrame as an argument to the ColumnDataSource constructor:

import numpy as np import pandas as pd from bokeh.models import ColumnDataSource # Create a sample Pandas DataFrame df = pd.DataFrame( np.array([ [33.9, 4, 65, 'US'], [32.4, 4, 66, 'Asia'], [21.4, 4, 109, 'Europe'] ]), columns=['mpg', 'cyl', 'hp', 'origin'], index=['Toyota', 'Fiat', 'Volvo'] ) # Convert the DataFrame to Bokeh ColumnDataSource cds_df = ColumnDataSource(df)

0

1

Updated 2026-07-04

Tags

Python Programming Language

Data Science

Learn After