# TODO: import the required dependencies
import pandas as pd
# Write code here
sql_query = """
SELECT country, revenue
FROM table_3196ce98cf3ce3223735e1d61022e9d2
ORDER BY revenue DESC
LIMIT 5;
"""
top_countries_df = execute_sql_query(sql_query)
# Declare result var
result = {
"type": "dataframe",
"value": top_countries_df
}
Last active
July 24, 2025 07:27
-
-
Save notsobad/6189c9b735a4d7525a1e0a5b10b7cf5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tables> | |
<table dialect="duckdb" table_name="table_1000_companies" columns="[{"name": "R&D Spend", "type": "float", "description": null, "expression": null, "alias": null}, {"name": "Administration", "type": "float", "description": null, "expression": null, "alias": null}, {"name": "Marketing Spend", "type": "float", "description": null, "expression": null, "alias": null}, {"name": "State", "type": "string", "description": null, "expression": null, "alias": null}, {"name": "Profit", "type": "float", "description": null, "expression": null, "alias": null}]" dimensions="1000x5"> | |
R&D Spend,Administration,Marketing Spend,State,Profit | |
165349.2,136897.8,471784.1,New York,192261.83 | |
162597.7,151377.59,443898.53,California,191792.06 | |
153441.51,101145.55,407934.54,Florida,191050.39 | |
144372.41,118671.85,383199.62,New York,182901.99 | |
142107.34,91391.77,366168.42,Florida,166187.94 | |
</table> | |
</tables> | |
You are already provided with the following functions that you can call: | |
<function> | |
def execute_sql_query(sql_query: str) -> pd.Dataframe | |
"""This method connects to the database, executes the sql query and returns the dataframe""" | |
</function> | |
Update this initial code: | |
```python | |
# TODO: import the required dependencies | |
import pandas as pd | |
# Write code here | |
# Declare result var: | |
type (possible values "string", "number", "dataframe", "plot"). Examples: { "type": "string", "value": f"The highest salary is {highest_salary}." } or { "type": "number", "value": 125 } or { "type": "dataframe", "value": pd.DataFrame({...}) } or { "type": "plot", "value": "temp_chart.png" } | |
``` | |
### QUERY | |
哪些公司的市场营销投入占比最高? | |
At the end, declare "result" variable as a dictionary of type and value. | |
Generate python code and return full updated code: | |
### Note: Use only relevant table for query and do aggregation, sorting, joins and grouby through sql query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tables> | |
<table dialect="duckdb" table_name="table_3196ce98cf3ce3223735e1d61022e9d2" columns="[{"name": "country", "type": "string", "description": null, "expression": null, "alias": null}, {"name": "revenue", "type": "integer", "description": null, "expression": null, "alias": null}]" dimensions="10x2"> | |
country,revenue | |
United States,5000 | |
United Kingdom,3200 | |
France,2900 | |
Germany,4100 | |
Italy,2300 | |
</table> | |
</tables> | |
You are already provided with the following functions that you can call: | |
<function> | |
def execute_sql_query(sql_query: str) -> pd.Dataframe | |
"""This method connects to the database, executes the sql query and returns the dataframe""" | |
</function> | |
Update this initial code: | |
```python | |
# TODO: import the required dependencies | |
import pandas as pd | |
# Write code here | |
# Declare result var: | |
type (possible values "string", "number", "dataframe", "plot"). Examples: { "type": "string", "value": f"The highest salary is {highest_salary}." } or { "type": "number", "value": 125 } or { "type": "dataframe", "value": pd.DataFrame({...}) } or { "type": "plot", "value": "temp_chart.png" } | |
``` | |
### QUERY | |
Which are the top 5 countries by sales? | |
At the end, declare "result" variable as a dictionary of type and value. | |
Generate python code and return full updated code: | |
### Note: Use only relevant table for query and do aggregation, sorting, joins and grouby through sql query |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment