> For the complete documentation index, see [llms.txt](https://vecco-insight.gitbook.io/crash-visualization/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vecco-insight.gitbook.io/crash-visualization/bokeh/5.2-data-sources.md).

# 5.2 Data Sources

In this section, we will explain several ways of providing data for plots.

### 1. Providing  directly

In Bokeh, it is possible to pass lists of values directly into plotting functions. In the example below, the data, `x_values` and `y_values`, are passed directly to the `circle` plotting method.

```
from bokeh.plotting import figure

x_values = [1, 2, 3, 4, 5]
y_values = [6, 7, 2, 3, 6]

p = figure()
p.circle(x=x_values, y=y_values)
```

When you pass in data like this, Bokeh works behind the scenes to make a `ColumnDataSource` for you. It is the core of most Bokeh plots, providing the data that is visualized by the glyphs of the plot. With the`ColumnDataSource` , it is easy to share data between multiple plots and widgets.

### 2. ColumnDataSource

At the most basic level, a `ColumnDataSource` is simply a mapping between column names and lists of data. Once the`ColumnDataSource`has been created, it can be passed into the`source`parameter of plotting methods which allows you to pass a column’s name as a stand-in for the data values.

```
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource

data = {'x_value': [1, 2, 3, 4, 5],
        'y_values': [6, 7, 2, 3, 6]}

source = ColumnDataSource(data=data)

p = figure()
p.circle(x='x_values', y='y_values', source=source)
```

### 3. Pandas

The `data`parameter can also be a Pandas `DataFrame` or `GroupBy` object.

```
source = ColumnDataSource(df)
```

Pandas  `GroupBy`.

```
group = df.groupby(('colA', 'ColB'))
source = ColumnDataSource(group)
```

### 4. Streaming

`ColumnDataSource` streaming is an efficient way to append new data to a CDS. By using the`stream`method, Bokeh only sends new data to the browser instead of the entire dataset.&#x20;

The `stream` method takes a `new_data` parameter containing a `dict` mapping column names to sequences of data to be appended to the respective columns.

```
source = ColumnDataSource(data=dict(foo=[], bar=[]))

# has new, identical-length updates for all columns in source
new_data = {
    'foo' : [10, 20],
    'bar' : [100, 200],
}

source.stream(new_data)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vecco-insight.gitbook.io/crash-visualization/bokeh/5.2-data-sources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
