|
|
|
|
@@ -14,11 +14,26 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 7,
|
|
|
|
|
"id": "0cdd9bf5",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"execution_count": null,
|
|
|
|
|
"id": "65a8ebbe-cd83-401a-8ca7-cb6541121d0c",
|
|
|
|
|
"metadata": {
|
|
|
|
|
"tags": []
|
|
|
|
|
},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"!pip install \"pandas\" > /dev/null"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 1,
|
|
|
|
|
"id": "0cdd9bf5",
|
|
|
|
|
"metadata": {
|
|
|
|
|
"tags": []
|
|
|
|
|
},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"from langchain.callbacks import tracing_enabled\n",
|
|
|
|
|
"from langchain.agents import create_pandas_dataframe_agent"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
@@ -26,7 +41,9 @@
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 2,
|
|
|
|
|
"id": "051ebe84",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"tags": []
|
|
|
|
|
},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"from langchain.llms import OpenAI\n",
|
|
|
|
|
@@ -37,17 +54,19 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 3,
|
|
|
|
|
"execution_count": 7,
|
|
|
|
|
"id": "4185ff46",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"tags": []
|
|
|
|
|
},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"agent = create_pandas_dataframe_agent(OpenAI(temperature=0), df, verbose=True)"
|
|
|
|
|
"agent = create_pandas_dataframe_agent(OpenAI(temperature=0), df, verbose=False)"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 4,
|
|
|
|
|
"execution_count": 9,
|
|
|
|
|
"id": "a9207a2e",
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [
|
|
|
|
|
@@ -55,32 +74,17 @@
|
|
|
|
|
"name": "stdout",
|
|
|
|
|
"output_type": "stream",
|
|
|
|
|
"text": [
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3mThought: I need to count the number of rows\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: len(df)\u001b[0m\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3m891\u001b[0m\n",
|
|
|
|
|
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n",
|
|
|
|
|
"Final Answer: There are 891 rows in the dataframe.\u001b[0m\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n"
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 1b224cee-9715-4f0b-ba33-527468c2cebb not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 51658270-136c-4763-9c8a-49db12e2efc9 not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"There are 891 rows.\n"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"text/plain": [
|
|
|
|
|
"'There are 891 rows in the dataframe.'"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"execution_count": 4,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"output_type": "execute_result"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"agent.run(\"how many rows are there?\")"
|
|
|
|
|
"with tracing_enabled():\n",
|
|
|
|
|
" print(agent.run(\"how many rows are there?\"))"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
@@ -96,11 +100,91 @@
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: how many people have more than 3 sibligngs\n",
|
|
|
|
|
"\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 6b86a7f0-bdf6-43e8-b94d-937c743b60f5 not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3mThought: I need to count the number of people with more than 3 siblings\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df[df['SibSp'] > 3].shape[0]\u001b[0m\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3m30\u001b[0m\n",
|
|
|
|
|
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n",
|
|
|
|
|
"Thought:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: how many people have more than 3 sibligngs\n",
|
|
|
|
|
"Thought: I need to count the number of people with more than 3 siblings\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df[df['SibSp'] > 3].shape[0]\n",
|
|
|
|
|
"Observation: 30\n",
|
|
|
|
|
"Thought:\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 73a825e3-1270-4735-b40b-208a0915e8be not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m I now know the final answer\n",
|
|
|
|
|
"Final Answer: 30 people have more than 3 siblings.\u001b[0m\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n"
|
|
|
|
|
@@ -134,23 +218,253 @@
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: whats the square root of the average age?\n",
|
|
|
|
|
"\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 8d771bc6-208a-4580-b43d-ec92ca04e39f not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3mThought: I need to calculate the average age first\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df['Age'].mean()\u001b[0m\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3m29.69911764705882\u001b[0m\n",
|
|
|
|
|
"Thought:\u001b[32;1m\u001b[1;3m I can now calculate the square root\n",
|
|
|
|
|
"Thought:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: whats the square root of the average age?\n",
|
|
|
|
|
"Thought: I need to calculate the average age first\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df['Age'].mean()\n",
|
|
|
|
|
"Observation: 29.69911764705882\n",
|
|
|
|
|
"Thought:\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID b30b9eac-eee3-406c-b7c3-a3db3b549948 not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m I now need to calculate the square root of the average age\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: math.sqrt(df['Age'].mean())\u001b[0m\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3mname 'math' is not defined\u001b[0m\n",
|
|
|
|
|
"Thought:\u001b[32;1m\u001b[1;3m I need to import the math library\n",
|
|
|
|
|
"Thought:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: whats the square root of the average age?\n",
|
|
|
|
|
"Thought: I need to calculate the average age first\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df['Age'].mean()\n",
|
|
|
|
|
"Observation: 29.69911764705882\n",
|
|
|
|
|
"Thought: I now need to calculate the square root of the average age\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: math.sqrt(df['Age'].mean())\n",
|
|
|
|
|
"Observation: name 'math' is not defined\n",
|
|
|
|
|
"Thought:\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 5c463668-dfa6-45e5-856d-2da5c91516d8 not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m I need to import the math library\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: import math\u001b[0m\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3mNone\u001b[0m\n",
|
|
|
|
|
"Thought:\u001b[32;1m\u001b[1;3m I can now calculate the square root\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3m\u001b[0m\n",
|
|
|
|
|
"Thought:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: whats the square root of the average age?\n",
|
|
|
|
|
"Thought: I need to calculate the average age first\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df['Age'].mean()\n",
|
|
|
|
|
"Observation: 29.69911764705882\n",
|
|
|
|
|
"Thought: I now need to calculate the square root of the average age\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: math.sqrt(df['Age'].mean())\n",
|
|
|
|
|
"Observation: name 'math' is not defined\n",
|
|
|
|
|
"Thought: I need to import the math library\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: import math\n",
|
|
|
|
|
"Observation: \n",
|
|
|
|
|
"Thought:\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 3e09fe75-cb84-4b8d-83a1-7037d8e12aab not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m I now need to calculate the square root of the average age\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: math.sqrt(df['Age'].mean())\u001b[0m\n",
|
|
|
|
|
"Observation: \u001b[36;1m\u001b[1;3m5.449689683556195\u001b[0m\n",
|
|
|
|
|
"Thought:\u001b[32;1m\u001b[1;3m I now know the final answer\n",
|
|
|
|
|
"Thought:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
|
|
|
|
|
"Prompt after formatting:\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m\n",
|
|
|
|
|
"You are working with a pandas dataframe in Python. The name of the dataframe is `df`.\n",
|
|
|
|
|
"You should use the tools below to answer the question posed of you:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Use the following format:\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Question: the input question you must answer\n",
|
|
|
|
|
"Thought: you should always think about what to do\n",
|
|
|
|
|
"Action: the action to take, should be one of [python_repl_ast]\n",
|
|
|
|
|
"Action Input: the input to the action\n",
|
|
|
|
|
"Observation: the result of the action\n",
|
|
|
|
|
"... (this Thought/Action/Action Input/Observation can repeat N times)\n",
|
|
|
|
|
"Thought: I now know the final answer\n",
|
|
|
|
|
"Final Answer: the final answer to the original input question\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"This is the result of `print(df.head())`:\n",
|
|
|
|
|
"| | PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked |\n",
|
|
|
|
|
"|---:|--------------:|-----------:|---------:|:----------------------------------------------------|:-------|------:|--------:|--------:|:-----------------|--------:|:--------|:-----------|\n",
|
|
|
|
|
"| 0 | 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S |\n",
|
|
|
|
|
"| 1 | 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence Briggs Thayer) | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C |\n",
|
|
|
|
|
"| 2 | 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. 3101282 | 7.925 | nan | S |\n",
|
|
|
|
|
"| 3 | 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily May Peel) | female | 35 | 1 | 0 | 113803 | 53.1 | C123 | S |\n",
|
|
|
|
|
"| 4 | 5 | 0 | 3 | Allen, Mr. William Henry | male | 35 | 0 | 0 | 373450 | 8.05 | nan | S |\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"Begin!\n",
|
|
|
|
|
"Question: whats the square root of the average age?\n",
|
|
|
|
|
"Thought: I need to calculate the average age first\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: df['Age'].mean()\n",
|
|
|
|
|
"Observation: 29.69911764705882\n",
|
|
|
|
|
"Thought: I now need to calculate the square root of the average age\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: math.sqrt(df['Age'].mean())\n",
|
|
|
|
|
"Observation: name 'math' is not defined\n",
|
|
|
|
|
"Thought: I need to import the math library\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: import math\n",
|
|
|
|
|
"Observation: \n",
|
|
|
|
|
"Thought: I now need to calculate the square root of the average age\n",
|
|
|
|
|
"Action: python_repl_ast\n",
|
|
|
|
|
"Action Input: math.sqrt(df['Age'].mean())\n",
|
|
|
|
|
"Observation: 5.449689683556195\n",
|
|
|
|
|
"Thought:\u001b[0m\n",
|
|
|
|
|
"Error in on_llm_start callback: Parent run with UUID 32e38f5f-a71a-4040-89c5-cca7752ba72d not found.\n",
|
|
|
|
|
"Error in on_llm_end callback: No LLMRun found to be traced\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n",
|
|
|
|
|
"\u001b[32;1m\u001b[1;3m I now know the final answer\n",
|
|
|
|
|
"Final Answer: 5.449689683556195\u001b[0m\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"\u001b[1m> Finished chain.\u001b[0m\n"
|
|
|
|
|
@@ -196,7 +510,7 @@
|
|
|
|
|
"name": "python",
|
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
|
"version": "3.9.1"
|
|
|
|
|
"version": "3.11.2"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"nbformat": 4,
|
|
|
|
|
|