> For the complete documentation index, see [llms.txt](https://docs.bdb.ai/7.6/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bdb.ai/7.6/data-pipeline/components/transformation/pandas-query-component.md). Agents can also search and read this documentation through its [MCP server](https://docs.bdb.ai/7.6/~gitbook/mcp).

# Pandas Query Component

Write basic python pandas query snippets for transformations.

All component configurations are classified broadly into 3 section

* [Basic ](https://docs.bdb.ai/7.6/data-pipeline/components/component-base-configuration.md)
* Metadata
* [Resource Configuration](https://docs.bdb.ai/7.6/data-pipeline/components/resource-configuration.md)

{% hint style="success" %}
*Follow the steps given in the demonstration to configure the Pandas Query component.*
{% endhint %}

![Configuring the Pandas Query Component](https://4128708524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FQ569HnMhxqB1PBIcQzno%2FPandas%20Query%20Component.gif?alt=media\&token=8f2496e3-d1c1-4027-96a1-4137778f3ea4)

## **Steps to Configure the Pandas Query Component**&#x20;

&#x20;This component helps the users to get data as per the entered query.&#x20;

* Drag and Drop the Pandas Query component to the Workflow Editor.  &#x20;

![Drag the Transformation group](https://4128708524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FjwJshWI8bl4QBbw09u2K%2Fimage.png?alt=media\&token=acdedb49-04f6-4b3a-905c-5041650eda4c)

* The transformation component requires an input event (to get the data) and sends the data to an output event.
* Create two Events and drag them to the Workspace.
* Connect the input event and the output event to the component (The data in the input event can come from any Ingestion, Reader, or shared events).

![Pandas Query Component](https://4128708524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FFDbBgS4IaoZdy36SX6ib%2Fimage.png?alt=media\&token=131c3b19-1be3-445a-a41b-27df76c92507)

* Click the Pandas Query component to get the component properties tabs.

### Basic Information Tab

The **Basic Information** tab opens by default while clicking the dragged component.

* Select an Invocation type from the drop-down menu to confirm the running mode of the Pandas Query component. Select ‘**Real-Time**’ or ‘**Batch**’ from the drop-down menu.
* **Deployment Type:** It displays the deployment type for the component. This field comes pre-selected.
* **Container Image Version**: It displays the image version for the docker container. This field comes pre-selected.
* **Failover Event**: Select a failover Event from the drop-down menu.
* **Batch Size (min 10)**: Provide the maximum number of records to be processed in one execution cycle (Min limit for this field is 10).

![](https://4128708524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2FAc96fKKJFx4t0l0K4DHL%2Fimage.png?alt=media\&token=25d690f4-93e1-46cf-968e-06fd8ca714df)

### Meta Information Tab

Open the **Meta Information** tab and provide the connection-specific detail&#x73;**.**

* Enter a valid data query to fetch data.
* Provide the Table Name.&#x20;

{% hint style="success" %}
Note: The table name and query DF should be the same.
{% endhint %}

### Saving the Component Configuration

* Click the **Save Component in Storage** icon to save the component properties.&#x20;
* A Notification message appears to notify the successful update of the component.

&#x20;    ![](https://4128708524-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGDmsjfjJBNqow7Fo97cO%2Fuploads%2F8VuodkH0vV6yYl6XIX87%2Fimage.png?alt=media\&token=42f31951-c63a-4dcf-8abe-bd5d404d262f)

{% hint style="info" %}
*<mark style="color:green;">Please Note</mark>: The samples of Pandas Query are given below together with the SQL query for the same statements.*
{% endhint %}

### &#x20;Sample Query Examples

| **SQL Query**                                                                                                                | **Pandas Query**                                                                                                                                         |
| ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| select id from airports where ident = 'KLAX'                                                                                 | airports \[airports.ident == 'KLAX'].id                                                                                                                  |
| select \* from airport\_freq where airport\_ident = 'KLAX' order by type                                                     | airports\[(airports.iso\_region == 'US-CA') & (airports.type == 'seaplane\_base')]                                                                       |
| select type, count(\*) from airports where iso\_country = 'US' group by type having count(\*) > 1000 order by count(\*) desc | <p>airports\[airports.iso\_country == 'US'].groupby('type').filter(lambda g: len(g) > 1000).groupby('type').size().sort\_values(ascending=False)<br></p> |
