pandasfruit


Namepandasfruit JSON
Version 1.4.1 PyPI version JSON
download
home_page
SummaryTakes a pandas dataframe and returns more-narrow narrow markdown string suitable for printing in a Jupyter notebook.
upload_time2023-11-27 17:15:17
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords pandas jupyter fit dataframe pdf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pandasfruit

## Summary
Takes in a pandas dataframe and returns a string containing markdown format where the width of the markdown text is more narrow and is suitable for printing. The more narrow table can fit on a printed page, such as a PDF generated from a Jupyter notebook.

Takes in an optional width parameter (number of characters) and will make the resulting markdown this wide. Else will use a default width of 115.

Also will use a default dictionary of words/abbreviations to shorten column names using the abbreviations instead of the original words. Alternatively, a  user-defined dictionary may be passed in. Pass in empty dictionary to do no replacements.

## Processing
To achieve the more-narrow markdown version of the df, first column names are shortened using the default abbreviations dictionary (or the optional user-provided dictionary). Keywords in column names are replaced with abbreviations. Note that column names may contain words separated by either underscores or spaces.

If, after wrapping column names, the width of the markdown is still greater than the desired markdown width, the columns are iteratively wrapped to increasingly shorter widths until the desired width of the markdown is achieved.

## Installation
pip install pandasfruit

## Usage
```python
import pandas as pd
from pandasfruit import pandasfruit
```

```python
x = pd.DataFrame(
    {
        'c foobar person number clean': [
            '00000001',
            '00000002',
            '00000003',
            '00000004',
            '00000005',
            '00000006',
            '00000007',
            '00000008'
        ],
        
        'c foobar first name clean': [
            'Eduard',
            'Andriel',
            'Faris',
            'Shaye',
            'Rodney',
            'Arledge',
            'Cory',
            'Madison'
        ],
        
        'c foobar last name clean': [
            'Davis',
            'Bell',
            'Russell',
            'Fisher',
            'Wilson',
            'Campbell',
            'Collins',
            'Thomas'
        ],
        
        'c _foobar_home_street_address_1_clean': [
        
            '1234 Maple Street REALLY REALLY REALLY SUPER REAL LONG '
            'STREET MORE MORE MORE WORDS SOME MORE',
            '5678 Oakwood Avenue',
            '910 Willow Lane',
            '1122 Elm Drive',
            '1314 Cedar Boulevard',
            '1516 Pine Court',
            '1718 Birch Road',
            '1920 Juniper Place REALLY REALLY REALLY SUPER DUPER LONG '
            'APARTMENT NAME EVEN MORE WORDS HERE OK SOME MORE'
        ],

        'c foobar home street address 2 clean': [
            'Apartment 200',
            'Suite 6 MORE MORE MORE AND EVEN MORE WORDS AND ADDING SOME '
            'MORE WORDS AND HERE ARE EVEN SOME MORE AND EVEN MORE WORDS '
            'ARE ADDED HERE OK',
            'Apt. 2',
            'Apartment 4021',
            '2nd Floor',
            'Unit C',
            'Apt. 3',
            'Downstairs'
        ]
    }
)
```
```python
print(x.to_markdown(tablefmt='grid'))
```

![](https://github.com/bol001/pandasfruit/assets/61277863/42abe0c8-4c92-41c3-9614-70c8e2444256)

```python
x_for_display = pandasfruit.df_to_fitted_markdown(x)

print(x_for_display)
```

![](https://github.com/bol001/pandasfruit/assets/61277863/1ef6b638-53ad-4387-ae74-9c39f73fdf6d)

```python
x_for_display = pandasfruit.df_to_fitted_markdown(x, width=80, abbreviations={'foo_bar': 'fb', 'baz ham': 'baz h'})
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pandasfruit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "pandas,jupyter,fit,dataframe,pdf",
    "author": "",
    "author_email": "bol001 <info@bollingensoftware.com>",
    "download_url": "https://files.pythonhosted.org/packages/4a/96/72dde5043ac28c4d607ae5cee8cd448da3b7d9fd9d960c418fb5cb38b68e/pandasfruit-1.4.1.tar.gz",
    "platform": null,
    "description": "# pandasfruit\n\n## Summary\nTakes in a pandas dataframe and returns a string containing markdown format where the width of the markdown text is more narrow and is suitable for printing. The more narrow table can fit on a printed page, such as a PDF generated from a Jupyter notebook.\n\nTakes in an optional width parameter (number of characters) and will make the resulting markdown this wide. Else will use a default width of 115.\n\nAlso will use a default dictionary of words/abbreviations to shorten column names using the abbreviations instead of the original words. Alternatively, a  user-defined dictionary may be passed in. Pass in empty dictionary to do no replacements.\n\n## Processing\nTo achieve the more-narrow markdown version of the df, first column names are shortened using the default abbreviations dictionary (or the optional user-provided dictionary). Keywords in column names are replaced with abbreviations. Note that column names may contain words separated by either underscores or spaces.\n\nIf, after wrapping column names, the width of the markdown is still greater than the desired markdown width, the columns are iteratively wrapped to increasingly shorter widths until the desired width of the markdown is achieved.\n\n## Installation\npip install pandasfruit\n\n## Usage\n```python\nimport pandas as pd\nfrom pandasfruit import pandasfruit\n```\n\n```python\nx = pd.DataFrame(\n    {\n        'c foobar person number clean': [\n            '00000001',\n            '00000002',\n            '00000003',\n            '00000004',\n            '00000005',\n            '00000006',\n            '00000007',\n            '00000008'\n        ],\n        \n        'c foobar first name clean': [\n            'Eduard',\n            'Andriel',\n            'Faris',\n            'Shaye',\n            'Rodney',\n            'Arledge',\n            'Cory',\n            'Madison'\n        ],\n        \n        'c foobar last name clean': [\n            'Davis',\n            'Bell',\n            'Russell',\n            'Fisher',\n            'Wilson',\n            'Campbell',\n            'Collins',\n            'Thomas'\n        ],\n        \n        'c _foobar_home_street_address_1_clean': [\n        \n            '1234 Maple Street REALLY REALLY REALLY SUPER REAL LONG '\n            'STREET MORE MORE MORE WORDS SOME MORE',\n            '5678 Oakwood Avenue',\n            '910 Willow Lane',\n            '1122 Elm Drive',\n            '1314 Cedar Boulevard',\n            '1516 Pine Court',\n            '1718 Birch Road',\n            '1920 Juniper Place REALLY REALLY REALLY SUPER DUPER LONG '\n            'APARTMENT NAME EVEN MORE WORDS HERE OK SOME MORE'\n        ],\n\n        'c foobar home street address 2 clean': [\n            'Apartment 200',\n            'Suite 6 MORE MORE MORE AND EVEN MORE WORDS AND ADDING SOME '\n            'MORE WORDS AND HERE ARE EVEN SOME MORE AND EVEN MORE WORDS '\n            'ARE ADDED HERE OK',\n            'Apt. 2',\n            'Apartment 4021',\n            '2nd Floor',\n            'Unit C',\n            'Apt. 3',\n            'Downstairs'\n        ]\n    }\n)\n```\n```python\nprint(x.to_markdown(tablefmt='grid'))\n```\n\n![](https://github.com/bol001/pandasfruit/assets/61277863/42abe0c8-4c92-41c3-9614-70c8e2444256)\n\n```python\nx_for_display = pandasfruit.df_to_fitted_markdown(x)\n\nprint(x_for_display)\n```\n\n![](https://github.com/bol001/pandasfruit/assets/61277863/1ef6b638-53ad-4387-ae74-9c39f73fdf6d)\n\n```python\nx_for_display = pandasfruit.df_to_fitted_markdown(x, width=80, abbreviations={'foo_bar': 'fb', 'baz ham': 'baz h'})\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Takes a pandas dataframe and returns more-narrow narrow markdown string suitable for printing in a Jupyter notebook.",
    "version": "1.4.1",
    "project_urls": {
        "Homepage": "https://github.com/bol001/pandasfruit",
        "Issues": "https://github.com/bol001/pandasfruit/issues"
    },
    "split_keywords": [
        "pandas",
        "jupyter",
        "fit",
        "dataframe",
        "pdf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c90e684a525c4969cce28b13180d372b71c0a8debb9b19df2f9886161fdfa64",
                "md5": "a85e388c763bc9aca55bec4babca9b68",
                "sha256": "1c3b0d8cf6ff1dc34ded6ff468c96759efa4a98c5c0f5cd44ac531f60e81429f"
            },
            "downloads": -1,
            "filename": "pandasfruit-1.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a85e388c763bc9aca55bec4babca9b68",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6212,
            "upload_time": "2023-11-27T17:15:16",
            "upload_time_iso_8601": "2023-11-27T17:15:16.455232Z",
            "url": "https://files.pythonhosted.org/packages/5c/90/e684a525c4969cce28b13180d372b71c0a8debb9b19df2f9886161fdfa64/pandasfruit-1.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a9672dde5043ac28c4d607ae5cee8cd448da3b7d9fd9d960c418fb5cb38b68e",
                "md5": "6835765b492715669da14b2db8e38b9c",
                "sha256": "679662cf6d339f9bb530628370903461e8ecfb8d27eda1bad6447980924c2782"
            },
            "downloads": -1,
            "filename": "pandasfruit-1.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6835765b492715669da14b2db8e38b9c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5738,
            "upload_time": "2023-11-27T17:15:17",
            "upload_time_iso_8601": "2023-11-27T17:15:17.515077Z",
            "url": "https://files.pythonhosted.org/packages/4a/96/72dde5043ac28c4d607ae5cee8cd448da3b7d9fd9d960c418fb5cb38b68e/pandasfruit-1.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-27 17:15:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "bol001",
    "github_project": "pandasfruit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pandasfruit"
}
        
Elapsed time: 0.51143s