a-pandas-ex-obj-into-cell


Namea-pandas-ex-obj-into-cell JSON
Version 0.12 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/a_pandas_ex_obj_into_cell
SummaryPuts objects into cells / columns of a Pandas Dataframe
upload_time2022-12-18 12:16:00
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords pandas dataframe dict list
VCS
bugtrack_url
requirements flatten_everything numpy pandas
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Puts objects into cells / columns of a Pandas Dataframe







```python

pip install a-pandas-ex-obj-into-cell

```

##### Not best (Pandas) practice, but sometimes very useful :)



```python



from a_pandas_ex_obj_into_cell import pd_add_obj_into_cells

import pandas as pd



pd_add_obj_into_cells()

df = pd.read_csv(

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

)



d1 = df.d_one_object_to_several_cells(

    column="test1",

    value=({1: ("xx", 331, 11)}),

    indexlist=[1, 2, 3, 7],

    ffill=True,

    bfill=True,

)



print(d1)

d2 = df.d_list_items_to_cells(

    column="test2",

    values=[

        [

            1,

            32,

            4,

        ],

        {33: "dfd", 0: [3, 2]},

        4,

        (5, 34),

    ],

    indexlist=[1, 4, 6, 9],

    ffill=False,

    bfill=False,

)

print(d2)





'''     

PassengerId  Survived  Pclass  ... Cabin Embarked                 test1

0              1         0       3  ...   NaN        S  {1: ('xx', 331, 11)}

1              2         1       1  ...   C85        C  {1: ('xx', 331, 11)}

2              3         1       3  ...   NaN        S  {1: ('xx', 331, 11)}

3              4         1       1  ...  C123        S  {1: ('xx', 331, 11)}

4              5         0       3  ...   NaN        S  {1: ('xx', 331, 11)}

..           ...       ...     ...  ...   ...      ...                   ...

886          887         0       2  ...   NaN        S  {1: ('xx', 331, 11)}

887          888         1       1  ...   B42        S  {1: ('xx', 331, 11)}

888          889         0       3  ...   NaN        S  {1: ('xx', 331, 11)}

889          890         1       1  ...  C148        C  {1: ('xx', 331, 11)}

890          891         0       3  ...   NaN        Q  {1: ('xx', 331, 11)}

[891 rows x 13 columns]

     PassengerId  Survived  Pclass  ... Cabin Embarked                   test2

0              1         0       3  ...   NaN        S                    <NA>

1              2         1       1  ...   C85        C              [1, 32, 4]

2              3         1       3  ...   NaN        S                    <NA>

3              4         1       1  ...  C123        S                    <NA>

4              5         0       3  ...   NaN        S  {33: 'dfd', 0: [3, 2]}

..           ...       ...     ...  ...   ...      ...                     ...

886          887         0       2  ...   NaN        S                     NaN

887          888         1       1  ...   B42        S                     NaN

888          889         0       3  ...   NaN        S                     NaN

889          890         1       1  ...  C148        C                     NaN

890          891         0       3  ...   NaN        Q                     NaN

[891 rows x 13 columns]'''



```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/a_pandas_ex_obj_into_cell",
    "name": "a-pandas-ex-obj-into-cell",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pandas,DataFrame,dict,list",
    "author": "Johannes Fischer",
    "author_email": "<aulasparticularesdealemaosp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/63/66/5ec05b3f7649eeee8dabb957fa899856b2140892e504a5f4206b10237e18/a_pandas_ex_obj_into_cell-0.12.tar.gz",
    "platform": null,
    "description": "\n# Puts objects into cells / columns of a Pandas Dataframe\n\n\n\n\n\n\n\n```python\n\npip install a-pandas-ex-obj-into-cell\n\n```\n\n##### Not best (Pandas) practice, but sometimes very useful :)\n\n\n\n```python\n\n\n\nfrom a_pandas_ex_obj_into_cell import pd_add_obj_into_cells\n\nimport pandas as pd\n\n\n\npd_add_obj_into_cells()\n\ndf = pd.read_csv(\n\n    \"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv\"\n\n)\n\n\n\nd1 = df.d_one_object_to_several_cells(\n\n    column=\"test1\",\n\n    value=({1: (\"xx\", 331, 11)}),\n\n    indexlist=[1, 2, 3, 7],\n\n    ffill=True,\n\n    bfill=True,\n\n)\n\n\n\nprint(d1)\n\nd2 = df.d_list_items_to_cells(\n\n    column=\"test2\",\n\n    values=[\n\n        [\n\n            1,\n\n            32,\n\n            4,\n\n        ],\n\n        {33: \"dfd\", 0: [3, 2]},\n\n        4,\n\n        (5, 34),\n\n    ],\n\n    indexlist=[1, 4, 6, 9],\n\n    ffill=False,\n\n    bfill=False,\n\n)\n\nprint(d2)\n\n\n\n\n\n'''     \n\nPassengerId  Survived  Pclass  ... Cabin Embarked                 test1\n\n0              1         0       3  ...   NaN        S  {1: ('xx', 331, 11)}\n\n1              2         1       1  ...   C85        C  {1: ('xx', 331, 11)}\n\n2              3         1       3  ...   NaN        S  {1: ('xx', 331, 11)}\n\n3              4         1       1  ...  C123        S  {1: ('xx', 331, 11)}\n\n4              5         0       3  ...   NaN        S  {1: ('xx', 331, 11)}\n\n..           ...       ...     ...  ...   ...      ...                   ...\n\n886          887         0       2  ...   NaN        S  {1: ('xx', 331, 11)}\n\n887          888         1       1  ...   B42        S  {1: ('xx', 331, 11)}\n\n888          889         0       3  ...   NaN        S  {1: ('xx', 331, 11)}\n\n889          890         1       1  ...  C148        C  {1: ('xx', 331, 11)}\n\n890          891         0       3  ...   NaN        Q  {1: ('xx', 331, 11)}\n\n[891 rows x 13 columns]\n\n     PassengerId  Survived  Pclass  ... Cabin Embarked                   test2\n\n0              1         0       3  ...   NaN        S                    <NA>\n\n1              2         1       1  ...   C85        C              [1, 32, 4]\n\n2              3         1       3  ...   NaN        S                    <NA>\n\n3              4         1       1  ...  C123        S                    <NA>\n\n4              5         0       3  ...   NaN        S  {33: 'dfd', 0: [3, 2]}\n\n..           ...       ...     ...  ...   ...      ...                     ...\n\n886          887         0       2  ...   NaN        S                     NaN\n\n887          888         1       1  ...   B42        S                     NaN\n\n888          889         0       3  ...   NaN        S                     NaN\n\n889          890         1       1  ...  C148        C                     NaN\n\n890          891         0       3  ...   NaN        Q                     NaN\n\n[891 rows x 13 columns]'''\n\n\n\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Puts objects into cells / columns of a Pandas Dataframe",
    "version": "0.12",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/a_pandas_ex_obj_into_cell"
    },
    "split_keywords": [
        "pandas",
        "dataframe",
        "dict",
        "list"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4874341f3cfc2a6c406501431715ff7885eb56d42306e25f12d067eb446f5a4",
                "md5": "c84cc3d4a36c646ce414ddb7bd23da8a",
                "sha256": "51026cf15e9f60fa263a464612fe33c20674cc4a87d616912c82bf1a5282f4ef"
            },
            "downloads": -1,
            "filename": "a_pandas_ex_obj_into_cell-0.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c84cc3d4a36c646ce414ddb7bd23da8a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6160,
            "upload_time": "2022-12-18T12:15:58",
            "upload_time_iso_8601": "2022-12-18T12:15:58.975367Z",
            "url": "https://files.pythonhosted.org/packages/e4/87/4341f3cfc2a6c406501431715ff7885eb56d42306e25f12d067eb446f5a4/a_pandas_ex_obj_into_cell-0.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63665ec05b3f7649eeee8dabb957fa899856b2140892e504a5f4206b10237e18",
                "md5": "3deb8966cc0c22c16db93589371f01bf",
                "sha256": "ca75f6cf3bbc7a2017364eb791c50ffc121a1186def53bc9cebb98295ee92700"
            },
            "downloads": -1,
            "filename": "a_pandas_ex_obj_into_cell-0.12.tar.gz",
            "has_sig": false,
            "md5_digest": "3deb8966cc0c22c16db93589371f01bf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4388,
            "upload_time": "2022-12-18T12:16:00",
            "upload_time_iso_8601": "2022-12-18T12:16:00.346451Z",
            "url": "https://files.pythonhosted.org/packages/63/66/5ec05b3f7649eeee8dabb957fa899856b2140892e504a5f4206b10237e18/a_pandas_ex_obj_into_cell-0.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-18 12:16:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "a_pandas_ex_obj_into_cell",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "flatten_everything",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        }
    ],
    "lcname": "a-pandas-ex-obj-into-cell"
}
        
Elapsed time: 2.08049s