Spaces:
Runtime error
Runtime error
Download utils.py from datastx/csv-analysis: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/spaces/datastx/csv-analysis/resolve/main/utils.py
- Command line
-
hf download hf://spaces/datastx/csv-analysis/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/datastx/csv-analysis/resolve/main/utils.py
620 Bytes
| from langchain.agents import create_pandas_dataframe_agent | |
| import pandas as pd | |
| from langchain.llms import OpenAI | |
| def query_agent(data, query): | |
| # Parse the CSV file and create a Pandas DataFrame from its contents. | |
| df = pd.read_csv(data) | |
| llm = OpenAI() | |
| # Create a Pandas DataFrame agent. | |
| agent = create_pandas_dataframe_agent(llm, df, verbose=True) | |
| #Python REPL: A Python shell used to evaluating and executing Python commands. | |
| #It takes python code as input and outputs the result. The input python code can be generated from another tool in the LangChain | |
| return agent.run(query) |