Coder Social home page Coder Social logo

isabella232 / pandas-highcharts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from robotsandpencils/pandas-highcharts

0.0 0.0 0.0 70 KB

Beautiful charting of pandas.DataFrame with Highcharts

License: MIT License

Jupyter Notebook 48.78% Python 51.22%

pandas-highcharts's Introduction

pandas-highcharts

image

image

What is it

pandas-highcharts is a Python package which allows you to easily build Highcharts plots with pandas.DataFrame objects.

Motivation

  • pandas is the best tool to handle data in Python
  • pandas is able to produce matplotlib plots. They work pretty well but have two major drawbacks
    • Not very web friendly
    • Pretty ugly
  • Highcharts produce nice, interactive plot in your browser and is very complete

Features

  • Same interface as DataFrame.plot
  • Following parameters are handled
    • data
    • x
    • y
    • kind
    • figsize
    • use_index
    • title
    • grid
    • legend
    • style
    • logx
    • logy
    • loglog
    • xticks
    • yticks
    • xlim
    • ylim
    • rot
    • fontsize
    • position
    • stacked
    • sort_columns
    • secondary_y
    • mark_right
  • Following parameters are not handled (yet) :
    • ax
    • ay
    • subplots
    • sharex
    • sharey
    • layout
    • colormap
    • colorbar
    • layout
    • table
    • yerr
    • xerr
    • kwds
  • You can specify those specific highcharts parameters:
    • tooltip
  • Static files (highcharts.js) are not embedded

Installation

Install the package using pip

pip install pandas-highcharts

Usage

Import it in your views

import pandas_highcharts
df = ... # create your dataframe here
chart = pandas_highcharts.serialize(df, render_to='my-chart', output_type='json')

In your templates

<div id="my-chart"></div>
<script type="text/javascript">
  new Highcharts.Chart({{chart|safe}});
</script>

Contributing

See CONTRIBUTING.rst for information on how to contribute to pandas-highcharts.

More examples

Some examples are available on nbviewer.

Please read the doc for DataFrame.plot.

For example, with the following dataset:

import pandas as pd
from pandas_highcharts.core import serialize
from pandas.compat import StringIO
dat = """ts;A;B;C
2015-01-01 00:00:00;27451873;29956800;113
2015-01-01 01:00:00;20259882;17906600;76
2015-01-01 02:00:00;11592256;12311600;48
2015-01-01 03:00:00;11795562;11750100;50
2015-01-01 04:00:00;9396718;10203900;43
2015-01-01 05:00:00;14902826;14341100;53"""
df = pd.read_csv(StringIO(dat), sep=';', index_col='ts', parse_dates='ts')

# Basic line plot
chart = serialize(df, render_to="my-chart", title="My Chart")
# Basic column plot
chart = serialize(df, render_to="my-chart", title="Test", kind="bar")
# Basic column plot
chart = serialize(df, render_to="my-chart", title="Test", kind="barh")
# Plot C on secondary axis
chart = serialize(df, render_to="my-chart", title="Test", secondary_y = ["C"])
# Plot on a 1000x700 div
chart = serialize(df, render_to="my-chart", title="Test", figsize = (1000, 700))

pandas-highcharts's People

Contributors

gtnx avatar garaud avatar spookylukey avatar iapain avatar

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.