GithubHelp home page GithubHelp logo

blaylockbk / pandas-rose Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 0.0 1.63 MB

🐼🌹 A simple Pandas accessor for making windrose plots.

Home Page: https://pandas-rose.readthedocs.io/

License: MIT License

Python 100.00%
pandas windrose

pandas-rose's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.