Skip to main content

A simple Pandas accessor to make windrose plots.

Project description

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 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.

pip install pandas-rose

Usage

Pandas-rose is simple.

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

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 .

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.

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

Alt text

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

Alt text

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas-rose-2023.8.0.tar.gz (975.2 kB view details)

Uploaded Source

Built Distribution

pandas_rose-2023.8.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pandas-rose-2023.8.0.tar.gz.

File metadata

  • Download URL: pandas-rose-2023.8.0.tar.gz
  • Upload date:
  • Size: 975.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pandas-rose-2023.8.0.tar.gz
Algorithm Hash digest
SHA256 3df7320f10bef172f23fa5a0679d12c7c13460dc47a585e831bbd1a8ef512451
MD5 8a98f576f54a961490abde3fd9c357f6
BLAKE2b-256 bce0be8a68888cc165e2822a348eda743b3df383acc2fcb628204b1dbc3eb787

See more details on using hashes here.

File details

Details for the file pandas_rose-2023.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pandas_rose-2023.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 345a09e393cc867ea8854d651142363f32f5906b84053044f492ac775459168e
MD5 6f6bdce5a1b9108db52975b76627e979
BLAKE2b-256 4880513179c205cffde40fe9e1aea3b04a9f22c002acaa4a22da70aff418371d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page