{"id":17623735,"url":"https://github.com/wiseaidev/polars-ai","last_synced_at":"2025-05-01T09:16:36.906Z","repository":{"id":206457239,"uuid":"715775959","full_name":"wiseaidev/polars-ai","owner":"wiseaidev","description":"💬 Chat with your Polars DataFrame from your CLI and your app! (WIP)","archived":false,"fork":false,"pushed_at":"2023-11-10T05:47:14.000Z","size":26,"stargazers_count":8,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-01T09:16:30.381Z","etag":null,"topics":["cli","dataframe","evcxr","jupyter","openai","polars","polars-ai","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/polars-ai","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wiseaidev.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-11-07T20:08:36.000Z","updated_at":"2025-02-18T03:44:07.000Z","dependencies_parsed_at":"2023-11-09T17:57:48.933Z","dependency_job_id":"e1e61f3b-a341-4c0e-b35c-1284776e6942","html_url":"https://github.com/wiseaidev/polars-ai","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"01d3112c8657094a3fc52953937b14950b7058c7"},"previous_names":["wiseaidev/polars-ai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fpolars-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fpolars-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fpolars-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiseaidev%2Fpolars-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiseaidev","download_url":"https://codeload.github.com/wiseaidev/polars-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251850182,"owners_count":21653978,"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":["cli","dataframe","evcxr","jupyter","openai","polars","polars-ai","rust"],"created_at":"2024-10-22T21:42:37.988Z","updated_at":"2025-05-01T09:16:36.867Z","avatar_url":"https://github.com/wiseaidev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polars AI 📊\n\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/wiseaidev)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![made-with-rust](https://img.shields.io/badge/Made%20with-Rust-1f425f.svg?logo=rust\u0026logoColor=white)](https://www.rust-lang.org/)\n[![Jupyter Notebook](https://img.shields.io/badge/Jupyter-Notebook-blue.svg?logo=Jupyter\u0026logoColor=orange)](https://jupyter.org/)\n[![Share On Reddit](https://img.shields.io/badge/share%20on-reddit-red?style=flat-square\u0026logo=reddit)](https://reddit.com/submit?url=https://github.com/wiseaidev/polars-ai\u0026amp;title=A%20CLI%20and%20a%20library%20for%20interacting%20with%20Polars%20DataFrames%20using%20natural%20language%20queries%20and%20AI.)\n[![Share On Ycombinator](https://img.shields.io/badge/share%20on-hacker%20news-orange?style=flat-square\u0026logo=ycombinator\u0026amp;w=256\u0026amp;q=751x)](https://news.ycombinator.com/submitlink?u=https://github.com/wiseaidev/polars-ai\u0026amp;t=A%20CLI%20and%20a%20library%20for%20interacting%20with%20Polars%20DataFrames%20using%20natural%20language%20queries%20and%20AI.)\n[![Share On Twitter](https://img.shields.io/badge/share%20on-twitter-03A9F4?style=flat-square\u0026logo=twitter\u0026amp;w=128\u0026amp;q=751x)](https://twitter.com/share?url=https://github.com/wiseaidev/polars-ai\u0026amp;text=A%20CLI%20and%20a%20library%20for%20interacting%20with%20Polars%20DataFrames%20using%20natural%20language%20queries%20and%20AI.)\n[![Share On Facebook](https://img.shields.io/badge/share%20on-facebook-1976D2?style=flat-square\u0026logo=facebook\u0026amp;w=256\u0026amp;q=751x)](https://www.facebook.com/sharer/sharer.php?u=https://github.com/wiseaidev/polars-ai)\n[![Share On Linkedin](https://img.shields.io/badge/share%20on-linkedin-3949AB?style=flat-square\u0026logo=linkedin\u0026amp;w=256\u0026amp;q=751x)](https://www.linkedin.com/shareArticle?url=https://github.com/wiseaidev/polars-ai\u0026amp;title=A%20CLI%20and%20a%20library%20for%20interacting%20with%20Polars%20DataFrames%20using%20natural%20language%20queries%20and%20AI.)\n\nPolars AI represents a pioneering utility featuring a command-line interface (CLI) complemented by a sophisticated crate/library. It empowers you to engage in conversational interactions with your [Polars](https://github.com/pola-rs/polars) DataFrames, harnessing the capabilities of AI for data analysis. Polars AI seamlessly integrates the formidable prowess of OpenAI's GPT-3.5 Turbo, thereby augmenting and optimizing data exploration and manipulation tasks.\n\nPolars AI allows you to:\n\n1. Chat with your Polars DataFrames using plain text queries.\n1. Perform data analysis tasks such as filtering, aggregating through AI-generated Rust code.\n1. Visualize data using charts and plots (coming soon).\n\n## Table of Contents 📚\n\n- [Installation](#installation-) 🚀\n- [Getting Started](#getting-started-) 🏁\n- [Usage](#usage-) 🧑‍💻\n- [Examples](#examples-) 💡\n- [Contributing](#contributing-) 🤝\n- [License](#license-) 📜\n\n## Installation 🚀\n\n### Install from source\n\nTo use Polars AI, you'll need to follow these installation steps:\n\n1. Install Rust (if not already installed) by following the instructions at [Rust Install](https://www.rust-lang.org/tools/install).\n\n1. Fork the repository on GitHub:\n   - Click the \"Fork\" button on the top right of the GitHub repository page.\n\n1. Clone the Polars AI repository to your local machine:\n\n   ```sh\n   $ git clone https://github.com/yourusername/polars-ai.git\n   ```\n\n1. Build the project using Rust's package manager, Cargo:\n\n   ```sh\n   $ cd polars-ai\n   $ cargo build --release\n   ```\n\n1. Set the OpenAI API key:\n\n   ```sh\n   $ export OPENAI_API_KEY=sk-\n   ```\n\n1. Run the CLI:\n\n   ```sh\n   $ ./target/release/polars-ai help\n   ```\n\n### Install using Cargo\n\nTo use Polars AI, you can also install it using Cargo, the Rust package manager:\n\n1. Build the project using Rust's package manager, Cargo:\n\n   ```sh\n   $ cargo install polars-ai\n   ```\n\n1. Set the OpenAI API key:\n\n   ```sh\n   $ export OPENAI_API_KEY=sk-\n   ```\n\n1. Run the CLI:\n\n   ```sh\n   $ polars-ai help\n   ```\n\n## Getting Started 🏁\n\nBefore you begin, make sure you have a Polars DataFrame that you want to analyze and interact with. Polars AI works with Polars DataFrames, so ensure that you have the necessary data loaded.\n\n## Usage 🧑‍💻\n\n### Chatting with Your DataFrames\n\nWith Polars AI, you can chat with your DataFrames using plain text queries. Simply enter your question or query when prompted by the CLI. For example:\n\n```sh\n$ export OPENAI_API_KEY=sk-\n\n$ polars-ai input -f examples/datasets/flights.csv show\n📊 DataFrame:\nshape: (18, 7)\n┌────────────┬───────────┬─────────┬─────────────────┬───────────────┬──────────┬──────────┐\n│ DayofMonth ┆ DayOfWeek ┆ Carrier ┆ OriginAirportID ┆ DestAirportID ┆ DepDelay ┆ ArrDelay │\n│ ---        ┆ ---       ┆ ---     ┆ ---             ┆ ---           ┆ ---      ┆ ---      │\n│ i64        ┆ i64       ┆ str     ┆ i64             ┆ i64           ┆ i64      ┆ i64      │\n╞════════════╪═══════════╪═════════╪═════════════════╪═══════════════╪══════════╪══════════╡\n│ 19         ┆ 5         ┆ DL      ┆ 11433           ┆ 13303         ┆ -3       ┆ 1        │\n│ 19         ┆ 5         ┆ DL      ┆ 14869           ┆ 12478         ┆ 0        ┆ -8       │\n│ 19         ┆ 5         ┆ DL      ┆ 14057           ┆ 14869         ┆ -4       ┆ -15      │\n│ 19         ┆ 5         ┆ DL      ┆ 15016           ┆ 11433         ┆ 28       ┆ 24       │\n│ …          ┆ …         ┆ …       ┆ …               ┆ …             ┆ …        ┆ …        │\n│ 19         ┆ 5         ┆ DL      ┆ 10397           ┆ 12451         ┆ 71       ┆ null     │\n│ 19         ┆ 5         ┆ DL      ┆ 12451           ┆ 10397         ┆ 75       ┆ null     │\n│ 19         ┆ 5         ┆ DL      ┆ 12953           ┆ 10397         ┆ -1       ┆ null     │\n│ 19         ┆ 5         ┆ DL      ┆ 11433           ┆ 12953         ┆ -3       ┆ null     │\n└────────────┴───────────┴─────────┴─────────────────┴───────────────┴──────────┴──────────┘\n\n$ polars-ai input -f examples/datasets/flights.csv ask -q 'What is the average of the first column?'\n\n🤖 AI Response:\n\nuse polars::prelude::*;\n\nfn analyze_data(dfs: Vec\u003cDataFrame\u003e) -\u003e Result\u003cDataFrame\u003e {\n    let df = \u0026dfs[0];\n\n    let avg_first_column = df\n        .select(\u0026[col(\"DayofMonth\")])\n        .expect(\"Column 'DayofMonth' must exist\")\n        .mean()\n        .unwrap()\n        .select(\u0026[col(\"mean\")])\n        .unwrap();\n\n    let top_carriers = df\n        .groupby(\u0026[col(\"Carrier\")])\n        .expect(\"Column 'Carrier' must exist\")\n        .mean()\n        .unwrap()\n        .sort(\u0026[col(\"mean\")], false)\n        .expect(\"Column 'mean' must exist\")\n        .head(Some(5))\n        .select(\u0026[col(\"Carrier\")])\n        .unwrap();\n\n    let result_df = df\n        .join(\u0026top_carriers, \u0026[col(\"Carrier\")], \u0026[col(\"Carrier\")], JoinType::Inner)\n        .expect(\"Column 'Carrier' must exist\")\n        .sort(\u0026[col(\"DayofMonth\")], false)\n        .expect(\"Column 'DayofMonth' must exist\")\n        .head(Some(5));\n\n    let final_result = result_df\n        .select(\u0026[col(\"Carrier\"), col(\"DayofMonth\")])\n        .unwrap();\n\n    Ok(final_result)\n}\n\nlet result = analyze_data(dfs);\nprintln!(\"{}\", result);\n```\n\nNow, based on the query above, you can run the Rust code.\n\n### Data Analysis Workflow\n\nThe generated Rust code follows a structured data analysis workflow:\n\n1. **Prepare:** Preprocess and clean the data if required.\n1. **Process:** Manipulate the data for analysis (e.g., grouping, filtering, aggregating).\n1. **Analyze:** Conduct the analysis.\n1. **Output:** Return results in various formats.\n\nYou can modify the generated code to customize your analysis.\n\n## Examples 💡\n\nRefer to [the examples folder](examples) to use Polars AI to analyze your data. Polars AI will generate Rust code to perform eda on the data.\n\n## Contributing 🤝\n\nWe welcome contributions to Polars AI! If you'd like to contribute to this project, please follow these steps:\n\n1. Fork the repository on GitHub:\n   - Click the \"Fork\" button on the top right of the GitHub repository page.\n\n1. Create a new branch for your feature or bug fix:\n   - Use the following Git command to create a new branch:\n\n     ```sh\n     $ git checkout -b feature-or-bugfix-branch\n     ```\n\n1. Make your changes and commit them:\n   - Edit the files in your local repository and use the following Git commands to commit your changes:\n\n     ```sh\n     $ git add .\n     $ git commit -m \"Your commit message here\"\n     ```\n\n1. Create a pull request with a clear description of your changes:\n   - Push your branch to your forked repository on GitHub and then create a pull request from there.\n\n     ```sh\n     $ git push origin feature-or-bugfix-branch\n     ```\n   - Visit your forked repository on GitHub, and you'll see an option to create a pull request for the branch you just pushed.\n\n## License 📜\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseaidev%2Fpolars-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiseaidev%2Fpolars-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiseaidev%2Fpolars-ai/lists"}