Skip to main content
A Dataset is a table of columns. A Results object retains interview and study information; calling results.select(...) produces a Dataset containing the selected columns. Use Dataset methods or pandas to transform and export that table. For example, select a treatment label and a rating from Results, filter to the observations you want, then export a CSV for your statistical software. You can do these steps directly in EDSL; converting with .to_pandas() is useful when you want pandas analyses or plotting. A ScenarioList is the corresponding collection of named records used as inputs to questions.

A complete local example

This example uses four fabricated scores and makes no model calls. It creates a Dataset from a DataFrame, filters and sorts rows, adds a derived column, and writes a CSV.
analysis_frame contains the two explicit rows with scores 5 and 4, in that order. with_flag contains all four rows plus the Boolean high_score column. selected_scores.csv contains only the selected rows.

Constructors and conversions

Use Dataset.from_pandas_dataframe(frame) for a pandas DataFrame. You can also construct a column-oriented table directly:
Keep columns the same length. to_pandas() preserves prefixed EDSL column names by default. Use qualified names when joining data so unrelated columns are not confused.

Common methods

This example filters a table and converts a single selected column to a Python list:
Conversion is optional when you only want to inspect the table. See Results for selecting columns from a completed study.

Reshape and inspect a table

For example, inspect the long representation of a small table:

Export and convert tables

These methods also apply to Results, ScenarioList, and AgentList. Select the fields you want before exporting: The CSV, Excel, and Word export methods above return FileStore objects. table.write("scores.csv") writes a file directly, choosing its format from the filename extension. table.to_json() returns a Python list of column dictionaries. Use json.dumps() when you need JSON text:
This differs from table.to_dict(), which returns the EDSL object structure that Dataset.from_dict() can reconstruct. Install the corresponding optional library for conversions such as to_polars() or Excel output. For database exports, convert to a pandas DataFrame and use its database-writing methods with your chosen connection and replacement policy.

Embed text

Text embeddings represent passages as lists of numbers that can be used to search for similar passages or group related responses. EmbeddingModel creates these representations; Dataset.embed() and ScenarioList.embed() add them as a column beside the source text. Embedding the text does not itself assign themes or create groups. Use qualitative coding when you want named themes from a codebook. This example uses fixed test vectors to show the table structure without a provider call. Their values do not represent semantic similarity:
For actual text embeddings, select an embedding model and service explicitly: EmbeddingModel(model_name="EMBEDDING_MODEL_NAME", service_name="openai") uses direct provider access by default. Configure the provider’s credentials. The sentence_transformers service runs locally with its dependencies and model weights installed; loading a model may download weights. remote=True routes supported embedding requests through Expected Parrot. Embedding models are separate from the language models selected with Model(). For text outside a Dataset, embedding_model.embed(["first text", "second text"], cache=embedding_cache) returns an EmbeddingResult. Its embeddings, input, model, service_name, usage, and cache_used attributes retain the vectors and available metadata. to_dataset() and to_scenario_list() convert it to EDSL tables; to_dict() and EmbeddingResult.from_dict(data) serialize and restore it. In asynchronous Python, use await embedding_model.async_embed(texts, cache=embedding_cache). EmbeddingCache(filename="embeddings.jsonl") loads existing embedding entries and writes new ones to that file. With immediate_write=False, call flush() to persist pending entries. This cache is separate from the response Cache used by survey runs. Embeddings and provider calls can incur costs; the test service above makes no paid calls.