{"id":28487772,"url":"https://github.com/mljar/enrichment","last_synced_at":"2025-07-01T19:31:11.980Z","repository":{"id":292127664,"uuid":"979881374","full_name":"mljar/enrichment","owner":"mljar","description":"Data enrichment with AI for pandas DataFrame","archived":false,"fork":false,"pushed_at":"2025-05-08T10:39:04.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-08T05:10:26.849Z","etag":null,"topics":["data-analysis","data-enrichment","data-science","openai","pandas"],"latest_commit_sha":null,"homepage":"https://mljar.com","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/mljar.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,"zenodo":null}},"created_at":"2025-05-08T08:06:40.000Z","updated_at":"2025-05-09T22:49:04.000Z","dependencies_parsed_at":"2025-05-08T09:59:39.036Z","dependency_job_id":null,"html_url":"https://github.com/mljar/enrichment","commit_stats":null,"previous_names":["mljar/enrichment"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mljar/enrichment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljar%2Fenrichment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljar%2Fenrichment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljar%2Fenrichment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljar%2Fenrichment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljar","download_url":"https://codeload.github.com/mljar/enrichment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljar%2Fenrichment/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263025074,"owners_count":23401716,"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":["data-analysis","data-enrichment","data-science","openai","pandas"],"created_at":"2025-06-08T05:07:54.404Z","updated_at":"2025-07-01T19:31:11.972Z","avatar_url":"https://github.com/mljar.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Enrichment with AI for Pandas DataFrame 🐼💰\n\nThe `enrichment` library lets you give your pandas DataFrame a new column data created with AI. Just tell it what you need in plain English. Need sentiment labels, clean addresses, language tags, or keywords? One call to `enrich()` adds a new column of results.\n\nWhy you’ll love it:\n- **Easy to use:** Pass in your DataFrame, describe what you want, and you’re done.\n- **Flexible:** Works with any OpenAI-style model—pick the balance you like between speed and cost.\n- **Ready for real work:** Built-in batching, progress bars, and smooth pandas integration.\n- **Anything you can name:** From sentiment and topics to translations and more—if you can write it, `enrich()` can handle it.\n\nGive it a try and watch your data come to life!\n\n## Examples\n\nBelow are several common enrichment tasks. Each example uses a DataFrame and demonstrates how to call `enrich` with an appropriate prompt, along with expected output.\n\n### 1. Sentiment Analysis\n```python\nimport pandas as pd\nfrom enrichment import enrich\n\n# Sample reviews\ndf_sentiment = pd.DataFrame({\n    \"review\": [\n        \"I loved the product, it was fantastic!\",\n        \"Terrible experience, will not buy again.\",\n        \"It was okay, nothing special.\",\n        \"Absolutely amazing, exceeded expectations!\",\n        \"Worst purchase ever, very disappointed.\"\n    ]\n})\n\n# Perform sentiment analysis\nenriched_sentiment = enrich(\n    df_sentiment,\n    input_col=\"review\",\n    output_col=\"sentiment\",\n    prompt=\"Classify sentiment\"\n)\nprint(enriched_sentiment)\n```\nExpected output:\n```plaintext\n                                       review sentiment\n0      I loved the product, it was fantastic!  Positive\n1    Terrible experience, will not buy again.  Negative\n2               It was okay, nothing special.   Neutral\n3  Absolutely amazing, exceeded expectations!  Positive\n4     Worst purchase ever, very disappointed.  Negative\n\n```\n\n### 2. Address Format Standardization \u0026 Cleaning\n```python\nimport pandas as pd\nfrom enrichment import enrich\n\n# Sample addresses\ndf_address = pd.DataFrame({\n    \"address\": [\n        \"123 main st., Apt#4, new york, ny\",\n        \"456 Elm Street Suite 5 Chicago IL\",\n        \"789 Broadway Blvd Los Angeles,CA\",\n        \"101 first avenue,San Francisco CA\",\n        \"202 Second St. Apt. 10, Boston MA\"\n    ]\n})\n\n# Standardize and clean addresses\nenriched_address = enrich(\n    df_address,\n    input_col=\"address\",\n    output_col=\"clean_address\",\n    prompt=\"Standardize and clean this address to a consistent format\"\n)\nprint(enriched_address)\n```\nExpected output:\n```plaintext\n                             address                                clean_address\n0  123 main st., Apt#4, new york, ny             123 Main St, Apt 4, New York, NY\n1  456 Elm Street Suite 5 Chicago IL               456 Elm St, Ste 5, Chicago, IL\n2   789 Broadway Blvd Los Angeles,CA           789 Broadway Blvd, Los Angeles, CA\n3  101 first avenue,San Francisco CA             101 First Ave, San Francisco, CA\n4  202 Second St. Apt. 10, Boston MA  202 Second Street, Apartment 10, Boston, MA\n\n```\n\n### 3. Keyword Extraction\n```python\nimport pandas as pd\nfrom enrichment import enrich\n\n# Sample text paragraphs\ndf_keywords = pd.DataFrame({\n    \"text\": [\n        \"ChatGPT is a powerful language model developed by OpenAI.\",\n        \"Python's pandas library is excellent for data manipulation.\",\n        \"The Eiffel Tower is one of the most famous landmarks in Paris.\",\n        \"Machine learning and AI are transforming industries.\",\n        \"Renewable energy sources include solar, wind, and hydroelectric power.\"\n    ]\n})\n\n# Extract keywords\nenriched_keywords = enrich(\n    df_keywords,\n    input_col=\"text\",\n    output_col=\"keywords\",\n    prompt=\"Extract the top 3 keywords\"\n)\nprint(enriched_keywords)\n```\nExpected output:\n```plaintext\n                                                text                          keywords\n0  ChatGPT is a powerful language model developed...   ChatGPT, language model, OpenAI\n1  Python's pandas library is excellent for data ...        pandas, data, manipulation\n2  The Eiffel Tower is one of the most famous lan...    Eiffel Tower, landmarks, Paris\n3  Machine learning and AI are transforming indus...  Machine learning, AI, industries\n4  Renewable energy sources include solar, wind, ...     renewable energy, solar, wind\n```\n\n### 4. Language Detection\n```python\nimport pandas as pd\nfrom enrichment import enrich\n\n# Sample multilingual sentences\ndf_language = pd.DataFrame({\n    \"sentence\": [\n        \"Bonjour, comment ça va?\",\n        \"Hello, how are you?\",\n        \"Hola, ¿cómo estás?\",\n        \"Hallo, wie geht es dir?\",\n        \"Ciao, come stai?\",\n        \"Cześć, jak się masz?\"\n    ]\n})\n\n\n# Detect language\nenriched_language = enrich(\n    df_language,\n    input_col=\"sentence\",\n    output_col=\"language\",\n    prompt=\"Detect the language of this sentence\"\n)\nprint(enriched_language)\n```\nExpected output:\n```plaintext\n                  sentence language\n0  Bonjour, comment ça va?   French\n1      Hello, how are you?  English\n2       Hola, ¿cómo estás?  Spanish\n3  Hallo, wie geht es dir?   German\n4         Ciao, come stai?  Italian\n5     Cześć, jak się masz?   Polish\n```\n\n### 5. Text Classification\n```python\nimport pandas as pd\nfrom enrichment import enrich\n\n# Sample news headlines\ndf_classify = pd.DataFrame({\n    \"headline\": [\n        \"Local team wins championship after dramatic final\",\n        \"New species of bird discovered in Amazon rainforest\",\n        \"Stock markets rally as tech stocks soar\",\n        \"Study reveals health benefits of green tea\",\n        \"Government announces new climate policy\"\n    ]\n})\n\n# Classify headlines into categories: sports, science, finance, health, politics\nenriched_classify = enrich(\n    df_classify,\n    input_col=\"headline\",\n    output_col=\"category\",\n    prompt=\"Classify this headline into one of: sports, science, finance, health, politics\"\n)\nprint(enriched_classify)\n```\nExpected output:\n```plaintext\n                                            headline  category\n0  Local team wins championship after dramatic final    sports\n1  New species of bird discovered in Amazon rainf...   science\n2            Stock markets rally as tech stocks soar   finance\n3         Study reveals health benefits of green tea    health\n4            Government announces new climate policy  politics\n\n```\n\n## Installation\n\nUse the following command to install this package:\n\n```bash\npip install enrichment\n```\n\n## API Reference\n\n```python\nenrich(\n    df: pandas.DataFrame,\n    input_col: str,\n    output_col: str,\n    prompt: str,\n    model: str = \"gpt-4.1\",\n    api_key: Optional[str] = None,\n    show_progress: bool = True\n) -\u003e pandas.DataFrame\n```\n\n| Parameter      | Type                 | Description                                                                                         |\n| -------------- | -------------------- | --------------------------------------------------------------------------------------------------- |\n| `df`           | `DataFrame`          | The source DataFrame containing text data.                                                         |\n| `input_col`    | `str`                | Column name in `df` holding the input text.                                                       |\n| `output_col`   | `str`                | Name of the new column to store enrichment results.                                               |\n| `prompt`       | `str`                | Task description; model receives `prompt` + input row, forced to output only the result.           |\n| `model`        | `str`, optional      | OpenAI model to use (default: `gpt-4.1`).                                                          |\n| `api_key`      | `str`, optional      | OpenAI API key. If omitted, reads from `OPENAI_API_KEY` environment variable.                      |\n| `show_progress`| `bool`, optional     | Display a tqdm progress bar (default: `True`; set `False` to hide).                                |\n\n**Returns:**\n\n- A new `pandas.DataFrame` identical to `df` but with `output_col` populated by model responses.\n\n**Raises:**\n\n- `ValueError` if the model key is not set via `api_key` or `OPENAI_API_KEY`.\n\n## Running Tests\n\nMake sure you have `pytest` installed, then run:\n\n```bash\npython -m pytest\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljar%2Fenrichment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljar%2Fenrichment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljar%2Fenrichment/lists"}