Skip to content

API Reference parrot.tools.pythonpandas

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.pythonpandas

View source

Alias AbstractTool

Re-exported from parrot.tools.abstract.AbstractTool.

Alias DatasetManager

Re-exported from parrot.tools.dataset_manager.DatasetManager.

Alias NamespaceTimeoutError

Re-exported from parrot.tools.repl_worker.NamespaceTimeoutError.

Class PythonPandasTool

Python Pandas Tool with pre-loaded DataFrames and enhanced data science capabilities.

Extends PythonREPLTool to provide:

  • Automatic DataFrame binding with ORIGINAL names as primary identifiers
  • Standardized aliases (df1, df2, etc.) as convenience references
  • Integration with DatasetManager for catalog/metadata operations
  • Enhanced data exploration utilities
  • Safe DataFrame operations

All metadata, EDA, column categorization, and data quality responsibilities are delegated to DatasetManager when available.

Parameter Type Default Description
dataframes Optional[Dict[str, pd.DataFrame]] None Dictionary of DataFrames to bind {name: DataFrame}. Ignored if dataset_manager is provided (use manager's catalog instead).
dataset_manager Optional['DatasetManager'] None DatasetManager instance for catalog/metadata operations. When provided, all metadata and catalog management is delegated.
df_prefix str 'df' Prefix for auto-generated DataFrame aliases (default: "df")
include_sample_data bool False Include sample data in guide
sample_rows int 3 Number of sample rows to show
**kwargs {} Additional arguments for PythonREPLTool

Attributes:

Attribute Type Description
dataset_manager Optional['DatasetManager'] Access the DatasetManager instance.
df_guide str Get the DataFrame guide from DatasetManager or cached value.

Method PythonPandasTool.reset_environment

Reset the REPL environment — also re-seeds df_locals on next use.

FEAT-380 (TASK-1944): a reset kills and replaces the worker (PythonREPLTool.reset_environment), so the DataFrames must be re-pushed into the fresh worker's empty namespace.

reset_environment() -> None

Method PythonPandasTool.create_session_clone

Create a lightweight, session-isolated clone of this tool.

The clone shares the heavy infrastructure (library imports, executor) but gets its own locals / globals dicts so concurrent requests cannot overwrite each other's DataFrames.

Eagerly-loaded DataFrames from the source tool are copied into the clone's namespace. Table-source DataFrames are NOT copied (they are query-specific and must be fetched per-turn).

create_session_clone(dataset_manager: Optional['DatasetManager'] = None) -> 'PythonPandasTool'

Parameter Type Default Description
dataset_manager Optional['DatasetManager'] None Session-scoped DatasetManager. When provided the clone will use it for alias maps and sync callbacks. When None, inherits from the source tool.

Returns: 'PythonPandasTool' — A new PythonPandasTool instance with isolated execution state.

Method PythonPandasTool.sync_from_manager

Synchronize execution environment from DatasetManager's active datasets.

Call this after adding/removing/activating/deactivating datasets in the DatasetManager to refresh the execution bindings.

sync_from_manager() -> None

Method PythonPandasTool.add_dataframe

Add a new DataFrame to the execution environment.

If a DatasetManager is attached, also registers it in the catalog.

add_dataframe(name: str, df: pd.DataFrame) -> str

Parameter Type Default Description
name str Name for the DataFrame
df pd.DataFrame The DataFrame to add

Returns: str — Success message with DataFrame key

Method PythonPandasTool.remove_dataframe

Remove a DataFrame from the execution environment.

If a DatasetManager is attached, also removes it from the catalog.

remove_dataframe(name: str) -> str

Parameter Type Default Description
name str Name of the DataFrame to remove

Returns: str — Success message

Method PythonPandasTool.register_dataframes

Register DataFrames to the tool execution environment.

Clears any previously registered DataFrames and binds the new ones. This is the preferred method for DatasetManager integration.

register_dataframes(dataframes: Dict[str, pd.DataFrame], alias_map: Optional[Dict[str, str]] = None) -> None

Parameter Type Default Description
dataframes Dict[str, pd.DataFrame] Dictionary mapping names to DataFrames
alias_map Optional[Dict[str, str]] None Optional stable alias mapping from DatasetManager (name → alias like df3). Ensures aliases in the REPL match what list_datasets advertises.

Method PythonPandasTool.clear_dataframes

Clear all registered DataFrames from the execution environment.

Removes DataFrame references from locals/globals and resets internal state.

FEAT-380 (TASK-1944) limitation: this only clears the HOST-side bookkeeping (.locals/.globals, kept for backward-compat readers per TASK-1943) and the worker-seeding tracker. The namespace API (TASK-1943) has no del_var/unset_var — there is currently no way to remove an already-pushed variable from a LIVE worker's namespace short of a full reset_environment() (which clears everything, not just DataFrames). Names cleared here are simply not re-pushed until register_dataframes()/sync_from_manager() runs again; if the worker is still alive, it keeps serving the old values in the meantime. Extending the namespace API with an unset primitive is a candidate follow-up, out of this task's scope.

clear_dataframes() -> None

Method PythonPandasTool.get_dataframe_guide

Get the current DataFrame guide.

get_dataframe_guide() -> str

Returns: str

Method PythonPandasTool.list_dataframes

List all available DataFrames with their info.

Delegates to DatasetManager if available, otherwise returns basic info.

list_dataframes() -> Dict[str, Dict[str, Any]]

Returns: Dict[str, Dict[str, Any]]

Method PythonPandasTool.get_dataframe_summary

Get detailed summary for a specific DataFrame.

Delegates to DatasetManager if available.

get_dataframe_summary(df_key: str) -> Dict[str, Any]

Parameter Type Default Description
df_key str

Returns: Dict[str, Any]

Method PythonPandasTool.get_environment_info

Override to include DataFrame information.

get_environment_info() -> Dict[str, Any]

Returns: Dict[str, Any]

Method PythonPandasTool.get_execution_state

Extract current execution state for use by formatters.

get_execution_state() -> Dict[str, Any]

Returns: Dict[str, Any] — Dictionary containing: - execution_results: All stored results - dataframes: Dict of available DataFrames - variables: Other variables from execution

Method PythonPandasTool.clear_execution_results

Clear execution_results dictionary for new queries.

clear_execution_results()

Alias PythonREPLArgs

Re-exported from parrot.tools.pythonrepl.PythonREPLArgs.

Alias PythonREPLTool

Re-exported from parrot.tools.pythonrepl.PythonREPLTool.

Alias WorkerBootstrapError

Re-exported from parrot.tools.repl_worker.WorkerBootstrapError.

Alias lazy_import

Re-exported from parrot._imports.lazy_import.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally