a-pandas-ex-lookupdict


Namea-pandas-ex-lookupdict JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/a_pandas_ex_lookupdict
SummaryCreates a lookup dict from a Pandas DataFrame (tuples as keys / np as values)
upload_time2022-12-18 06:18:28
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords pandas dataframe lookup dict
VCS
bugtrack_url
requirements numpy pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Creates a lookup dict from a Pandas DataFrame (tuples as keys / np as values)



```python

pip install a-pandas-ex-lookupdict

```





```python



from a_pandas_ex_lookupdict import pd_add_lookup_dict

import pandas as pd

pd_add_lookup_dict()

df = pd.read_csv(

    "https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv"

)

di1 = df[:5].d_get_lookup_dict(as_index=["Name", "PassengerId"])

di2 = df[:5].d_get_lookup_dict(

    as_values=["Cabin", "Fare"], as_index=["Name", "PassengerId"]

)



di1

Out[4]: 

{('Braund, Mr. Owen Harris',

  1): array([[0, 3, 'male', 22.0, 1, 0, 'A/5 21171', 7.25, nan, 'S']],

       dtype=object),

 ('Cumings, Mrs. John Bradley (Florence Briggs Thayer)',

  2): array([[1, 1, 'female', 38.0, 1, 0, 'PC 17599', 71.2833, 'C85', 'C']],

       dtype=object),

 ('Heikkinen, Miss. Laina',

  3): array([[1, 3, 'female', 26.0, 0, 0, 'STON/O2. 3101282', 7.925, nan, 'S']],

       dtype=object),

 ('Futrelle, Mrs. Jacques Heath (Lily May Peel)',

  4): array([[1, 1, 'female', 35.0, 1, 0, '113803', 53.1, 'C123', 'S']],

       dtype=object)}

	   

	   

di2

Out[5]: 

{('Braund, Mr. Owen Harris', 1): array([[nan, 7.25]], dtype=object),

 ('Cumings, Mrs. John Bradley (Florence Briggs Thayer)',

  2): array([['C85', 71.2833]], dtype=object),

 ('Heikkinen, Miss. Laina', 3): array([[nan, 7.925]], dtype=object),

 ('Futrelle, Mrs. Jacques Heath (Lily May Peel)',

  4): array([['C123', 53.1]], dtype=object)}



```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/a_pandas_ex_lookupdict",
    "name": "a-pandas-ex-lookupdict",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pandas,DataFrame,lookup,dict",
    "author": "Johannes Fischer",
    "author_email": "<aulasparticularesdealemaosp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c8/4e/722fe54aca85ae5d6af978a870d6a2e92f3d91542a8b0454e98de5ef1633/a_pandas_ex_lookupdict-0.11.tar.gz",
    "platform": null,
    "description": "\n# Creates a lookup dict from a Pandas DataFrame (tuples as keys / np as values)\n\n\n\n```python\n\npip install a-pandas-ex-lookupdict\n\n```\n\n\n\n\n\n```python\n\n\n\nfrom a_pandas_ex_lookupdict import pd_add_lookup_dict\n\nimport pandas as pd\n\npd_add_lookup_dict()\n\ndf = pd.read_csv(\n\n    \"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv\"\n\n)\n\ndi1 = df[:5].d_get_lookup_dict(as_index=[\"Name\", \"PassengerId\"])\n\ndi2 = df[:5].d_get_lookup_dict(\n\n    as_values=[\"Cabin\", \"Fare\"], as_index=[\"Name\", \"PassengerId\"]\n\n)\n\n\n\ndi1\n\nOut[4]: \n\n{('Braund, Mr. Owen Harris',\n\n  1): array([[0, 3, 'male', 22.0, 1, 0, 'A/5 21171', 7.25, nan, 'S']],\n\n       dtype=object),\n\n ('Cumings, Mrs. John Bradley (Florence Briggs Thayer)',\n\n  2): array([[1, 1, 'female', 38.0, 1, 0, 'PC 17599', 71.2833, 'C85', 'C']],\n\n       dtype=object),\n\n ('Heikkinen, Miss. Laina',\n\n  3): array([[1, 3, 'female', 26.0, 0, 0, 'STON/O2. 3101282', 7.925, nan, 'S']],\n\n       dtype=object),\n\n ('Futrelle, Mrs. Jacques Heath (Lily May Peel)',\n\n  4): array([[1, 1, 'female', 35.0, 1, 0, '113803', 53.1, 'C123', 'S']],\n\n       dtype=object)}\n\n\t   \n\n\t   \n\ndi2\n\nOut[5]: \n\n{('Braund, Mr. Owen Harris', 1): array([[nan, 7.25]], dtype=object),\n\n ('Cumings, Mrs. John Bradley (Florence Briggs Thayer)',\n\n  2): array([['C85', 71.2833]], dtype=object),\n\n ('Heikkinen, Miss. Laina', 3): array([[nan, 7.925]], dtype=object),\n\n ('Futrelle, Mrs. Jacques Heath (Lily May Peel)',\n\n  4): array([['C123', 53.1]], dtype=object)}\n\n\n\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Creates a lookup dict from a Pandas DataFrame (tuples as keys / np as values)",
    "version": "0.11",
    "split_keywords": [
        "pandas",
        "dataframe",
        "lookup",
        "dict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "d1752361ef650f86c0bede93c5f43b21",
                "sha256": "d92f4bd19ff39a1c3d614f82ed85a3c3c5b2895bcbafebe6f55f4ce543279045"
            },
            "downloads": -1,
            "filename": "a_pandas_ex_lookupdict-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d1752361ef650f86c0bede93c5f43b21",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5632,
            "upload_time": "2022-12-18T06:18:27",
            "upload_time_iso_8601": "2022-12-18T06:18:27.235867Z",
            "url": "https://files.pythonhosted.org/packages/a7/65/f3a826d7bf1164cb2002b4bc419425723606f789c97ab30b4af089b1e045/a_pandas_ex_lookupdict-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "f76b9bb0bd6e7e9f32dbe3749cbc0771",
                "sha256": "2de445cc6c2efd5d95f90e0e8f5a2ec156600e1ea58d412f2555d4d38de2505a"
            },
            "downloads": -1,
            "filename": "a_pandas_ex_lookupdict-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "f76b9bb0bd6e7e9f32dbe3749cbc0771",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3936,
            "upload_time": "2022-12-18T06:18:28",
            "upload_time_iso_8601": "2022-12-18T06:18:28.824005Z",
            "url": "https://files.pythonhosted.org/packages/c8/4e/722fe54aca85ae5d6af978a870d6a2e92f3d91542a8b0454e98de5ef1633/a_pandas_ex_lookupdict-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-18 06:18:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "hansalemaos",
    "github_project": "a_pandas_ex_lookupdict",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        }
    ],
    "lcname": "a-pandas-ex-lookupdict"
}
        
Elapsed time: 0.05784s