pandas-rose


Namepandas-rose JSON
Version 2023.8.0 PyPI version JSON
download
home_page
SummaryA simple Pandas accessor to make windrose plots.
upload_time2023-08-03 14:22:40
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2023 Brian K. Blaylock Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords weather meteorology wind
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align=center>

<img src="https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/pandas-rose.png" title="Bing Image Creator: Cartoon chunky panda hugging rose in the wind pixel art " width=200>

</div>

# Pandas Rose

This python package adds a custom Pandas accessor to generate polar wind rose plots from a Pandas dataframe.

I don't mean to compete with the wonderful [windrose](https://github.com/python-windrose/windrose) package already available, but that package has a little too much complexity for what I wanted. This package is meant to provide a minimal, simple interface to making wind rose plots. This is done by using Pandas methods `pd.cut` and `df.groupby` and using Matplotlib regular polar axes.

# Install

Install with pip. The requirements are only pandas, numpy, and matplotlib.

```bash
pip install pandas-rose
```

# Usage

Pandas-rose is simple.

```python
import pandas as pd
import rose

# df is a pandas dataframe with columns
# "wind_speed" and "wind_direction"
df = pd.DataFrame({
    "wind_speed":[1,2,3,4],
    "wind_direction":[20, 10, 190,300]
})

# Display a polar wind plot of the data
df.rose.plot()
```

![Alt text](https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/sample_plot.png)

You can specify the pandas column to use for wind direction and wind speed. You may also change the number of sectors to bin the wind direction .

```python
df.rose.plot(
    var_column="A",    # name of variable column
    dir_column="B",    # name of direction column
    sectors=8,         # number of sectors (direction bins)
    bins=range(0,30,5) # specify variable bins
    normed=False       # If True, values as percentage instead of counts
    colors='Blues'     # Name of matplotlib colormap or list of colors
    )
```

There are two other accessors that give some information.

```python
# Display a dataframe of the binned values
df.rose.table(sectors=8)
```

![Alt text](https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/sample_table.png)

```python
# Display the binned data as bar graph on regular axes.
df.rose.bar()
```

![Alt text](https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/sample_bar.png)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pandas-rose",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Brian Blaylock <blaylockbk@gmail.com>",
    "keywords": "weather,meteorology,wind",
    "author": "",
    "author_email": "Brian Blaylock <blaylockbk@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bc/e0/be8a68888cc165e2822a348eda743b3df383acc2fcb628204b1dbc3eb787/pandas-rose-2023.8.0.tar.gz",
    "platform": null,
    "description": "<div align=center>\n\n<img src=\"https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/pandas-rose.png\" title=\"Bing Image Creator: Cartoon chunky panda hugging rose in the wind pixel art \" width=200>\n\n</div>\n\n# Pandas Rose\n\nThis python package adds a custom Pandas accessor to generate polar wind rose plots from a Pandas dataframe.\n\nI don't mean to compete with the wonderful [windrose](https://github.com/python-windrose/windrose) package already available, but that package has a little too much complexity for what I wanted. This package is meant to provide a minimal, simple interface to making wind rose plots. This is done by using Pandas methods `pd.cut` and `df.groupby` and using Matplotlib regular polar axes.\n\n# Install\n\nInstall with pip. The requirements are only pandas, numpy, and matplotlib.\n\n```bash\npip install pandas-rose\n```\n\n# Usage\n\nPandas-rose is simple.\n\n```python\nimport pandas as pd\nimport rose\n\n# df is a pandas dataframe with columns\n# \"wind_speed\" and \"wind_direction\"\ndf = pd.DataFrame({\n    \"wind_speed\":[1,2,3,4],\n    \"wind_direction\":[20, 10, 190,300]\n})\n\n# Display a polar wind plot of the data\ndf.rose.plot()\n```\n\n![Alt text](https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/sample_plot.png)\n\nYou can specify the pandas column to use for wind direction and wind speed. You may also change the number of sectors to bin the wind direction .\n\n```python\ndf.rose.plot(\n    var_column=\"A\",    # name of variable column\n    dir_column=\"B\",    # name of direction column\n    sectors=8,         # number of sectors (direction bins)\n    bins=range(0,30,5) # specify variable bins\n    normed=False       # If True, values as percentage instead of counts\n    colors='Blues'     # Name of matplotlib colormap or list of colors\n    )\n```\n\nThere are two other accessors that give some information.\n\n```python\n# Display a dataframe of the binned values\ndf.rose.table(sectors=8)\n```\n\n![Alt text](https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/sample_table.png)\n\n```python\n# Display the binned data as bar graph on regular axes.\ndf.rose.bar()\n```\n\n![Alt text](https://raw.githubusercontent.com/blaylockbk/pandas-rose/main/images/sample_bar.png)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Brian K. Blaylock  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A simple Pandas accessor to make windrose plots.",
    "version": "2023.8.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/blaylockbk/pandas-rose/issues",
        "Changelog": "https://github.com/blaylockbk/pandas-rose/releases",
        "Documentation": "https://github.com/blaylockbk/pandas-rose",
        "Homepage": "https://github.com/blaylockbk/pandas-rose",
        "Repository": "https://github.com/blaylockbk/pandas-rose"
    },
    "split_keywords": [
        "weather",
        "meteorology",
        "wind"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4880513179c205cffde40fe9e1aea3b04a9f22c002acaa4a22da70aff418371d",
                "md5": "6f6bdce5a1b9108db52975b76627e979",
                "sha256": "345a09e393cc867ea8854d651142363f32f5906b84053044f492ac775459168e"
            },
            "downloads": -1,
            "filename": "pandas_rose-2023.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f6bdce5a1b9108db52975b76627e979",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6905,
            "upload_time": "2023-08-03T14:22:39",
            "upload_time_iso_8601": "2023-08-03T14:22:39.018350Z",
            "url": "https://files.pythonhosted.org/packages/48/80/513179c205cffde40fe9e1aea3b04a9f22c002acaa4a22da70aff418371d/pandas_rose-2023.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bce0be8a68888cc165e2822a348eda743b3df383acc2fcb628204b1dbc3eb787",
                "md5": "8a98f576f54a961490abde3fd9c357f6",
                "sha256": "3df7320f10bef172f23fa5a0679d12c7c13460dc47a585e831bbd1a8ef512451"
            },
            "downloads": -1,
            "filename": "pandas-rose-2023.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8a98f576f54a961490abde3fd9c357f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 975211,
            "upload_time": "2023-08-03T14:22:40",
            "upload_time_iso_8601": "2023-08-03T14:22:40.695476Z",
            "url": "https://files.pythonhosted.org/packages/bc/e0/be8a68888cc165e2822a348eda743b3df383acc2fcb628204b1dbc3eb787/pandas-rose-2023.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-03 14:22:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "blaylockbk",
    "github_project": "pandas-rose",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pandas-rose"
}
        
Elapsed time: 0.09973s