{"id":18077384,"url":"https://github.com/parisneo/gpt4pandas","last_synced_at":"2025-04-12T09:25:18.278Z","repository":{"id":161221900,"uuid":"635956826","full_name":"ParisNeo/gpt4pandas","owner":"ParisNeo","description":"The power of GPT4All mixed with the power of pandas","archived":false,"fork":false,"pushed_at":"2023-05-05T07:45:18.000Z","size":36,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T17:41:04.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ParisNeo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-03T20:25:27.000Z","updated_at":"2025-02-16T14:28:15.000Z","dependencies_parsed_at":"2023-06-07T06:30:19.721Z","dependency_job_id":null,"html_url":"https://github.com/ParisNeo/gpt4pandas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fgpt4pandas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fgpt4pandas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fgpt4pandas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ParisNeo%2Fgpt4pandas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ParisNeo","download_url":"https://codeload.github.com/ParisNeo/gpt4pandas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248545129,"owners_count":21122081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-31T11:24:28.700Z","updated_at":"2025-04-12T09:25:18.265Z","avatar_url":"https://github.com/ParisNeo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GPT4Pandas\n[![Follow me on Twitter](https://img.shields.io/twitter/follow/SpaceNerduino?style=social)](https://twitter.com/SpaceNerduino)\n[![Follow Me on YouTube](https://img.shields.io/badge/Follow%20Me%20on-YouTube-red?style=flat\u0026logo=youtube)](https://www.youtube.com/user/Parisneo)\n\n\nGPT4Pandas is a tool that uses the GPT4ALL language model and the Pandas library to answer questions about dataframes. With this tool, you can easily get answers to questions about your dataframes without needing to write any code.\n\n## Installation\n\nTo install GPT4ALL Pandas Q\u0026A, you can use pip:\n```bash\npip install gpt4pandas\n```\n\n## Usage\n\nTo use GPT4ALL Pandas Q\u0026A, you can import the `GPT4Pandas` class and create an instance of it with your dataframe:\n```python\nimport pandas as pd\nfrom gpt4pandas import GPT4Pandas\n# Load a sample dataframe\ndata = {\n    \"Name\": [\"Alice\", \"Bob\", \"Charlie\"],\n    \"Age\": [25, 30, 35],\n    \"City\": [\"New York\", \"Paris\", \"London\"],\n    \"Salary\": [50000, 60000, 70000],\n}\ndf = pd.DataFrame(data)\n\n# Initialize the GPT4Pandas model\nmodel_path = \u003cthe path to the model file\u003e\ngpt = GPT4Pandas(model_path, df, verbose=False)\n```\n\nThen ask a question about your dataframe:\n\n```python\n# Ask a question about the dataframe\nquestion = \"What is the average salary?\"\nprint(question)\nanswer = gpt.ask(question)\nprint(answer)  # Output: \"mean(Salary)\"\n```\n\nHere is a complete example that you can also find in examples folder :\n\n```python\nimport pandas as pd\nfrom gpt4pandas import GPT4Pandas\nfrom pathlib import Path\nfrom tqdm import tqdm\nimport urllib\nimport sys\n\n# If there is no model, then download one \n# These models can be automatically downloaded, uncomment the model you want to use\n# url = \"https://huggingface.co/ParisNeo/GPT4All/resolve/main/gpt4all-lora-quantized-ggml.bin\"\n# url = \"https://huggingface.co/ParisNeo/GPT4All/resolve/main/gpt4all-lora-unfiltered-quantized.new.bin\"\n# url = \"https://huggingface.co/eachadea/legacy-ggml-vicuna-7b-4bit/resolve/main/ggml-vicuna-7b-4bit-rev1.bin\"\nurl = \"https://huggingface.co/eachadea/ggml-vicuna-13b-4bit/resolve/main/ggml-vicuna-13b-4bit-rev1.bin\"\nmodel_name  = url.split(\"/\")[-1]\nfolder_path = Path(\"models/\")\n\nmodel_full_path = (folder_path / model_name)\n\n# ++++++++++++++++++++ Model downloading +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n# Check if file already exists in folder\nif model_full_path.exists():\n    print(\"File already exists in folder\")\nelse:\n    # Create folder if it doesn't exist\n    folder_path.mkdir(parents=True, exist_ok=True)\n    progress_bar = tqdm(total=None, unit=\"B\", unit_scale=True, desc=f\"Downloading {url.split('/')[-1]}\")\n    # Define callback function for urlretrieve\n    def report_progress(block_num, block_size, total_size):\n        progress_bar.total=total_size\n        progress_bar.update(block_size)\n    # Download file from URL to folder\n    try:\n        urllib.request.urlretrieve(url, folder_path / url.split(\"/\")[-1], reporthook=report_progress)\n        print(\"File downloaded successfully!\")\n    except Exception as e:\n        print(\"Error downloading file:\", e)\n        sys.exit(1)\n# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n# Load a sample dataframe\ndata = {\n    \"Name\": [\"Alice\", \"Bob\", \"Charlie\"],\n    \"Age\": [25, 30, 35],\n    \"City\": [\"New York\", \"Paris\", \"London\"],\n    \"Salary\": [50000, 60000, 70000],\n}\ndf = pd.DataFrame(data)\n\n# Initialize the GPT4Pandas model\nmodel_path = \"models/\"+model_name\ngpt = GPT4Pandas(model_path, df, verbose=False)\n\nprint(\"Dataframe\")\nprint(df)\n# Ask a question about the dataframe\nquestion = \"What is the average salary?\"\nprint(question)\nanswer = gpt.ask(question)\nprint(answer)  # Output: \"mean(Salary)\"\n\n# Ask another question\nquestion = \"Which person is youngest?\"\nprint(question)\nanswer = gpt.ask(question)\nprint(answer)  # Output: \"max(Age)\"\n\n# Set a new dataframe and ask a question\nnew_data = {\n    \"Name\": [\"David\", \"Emily\"],\n    \"Age\": [40, 45],\n    \"City\": [\"Berlin\", \"Tokyo\"],\n    \"Salary\": [80000, 90000],\n}\nnew_df = pd.DataFrame(new_data)\nprint(\"Dataframe\")\nprint(new_df)\n\ngpt.set_dataframe(new_df)\nquestion = \"What is salary in Tokyo?\"\nprint(question)\nanswer = gpt.ask(question)\nprint(answer)  # Output: \"min(Salary) where City is Tokyo\"\n```\n\nThis will output the answer to your question.\nHere is one of the answers :\n\n```\nDataframe\n      Name  Age      City  Salary\n0    Alice   25  New York   50000\n1      Bob   30     Paris   60000\n2  Charlie   35    London   70000\nWhat is the average salary?\nThe average salary is $60,000.\nWhich person is youngest?\nAlice is the youngest.\nDataframe\n    Name  Age    City  Salary\n0  David   40  Berlin   80000\n1  Emily   45   Tokyo   90000\nWhat is salary in Tokyo?\nThe salary in Tokyo is $90,000.\n```\ntested using vcuna 13B model.\n\n# limitations\n\nPlease notice that the results depend on the model size, context size and dataframe size. if the dataframe is bigger than the context, you'll have an error.\n\n\n# License\nGPT4ALL Pandas Q\u0026A is licensed under the Apache License, Version 2.0. See the LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fgpt4pandas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparisneo%2Fgpt4pandas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparisneo%2Fgpt4pandas/lists"}