Skip to content

Commit

Permalink
Merge pull request #132 from PatrikHlobil/#128--fix-broken-import
Browse files Browse the repository at this point in the history
update poetry config
  • Loading branch information
PatrikHlobil authored Mar 6, 2023
2 parents d67cdbe + 203b1bf commit bb4181c
Show file tree
Hide file tree
Showing 14 changed files with 505 additions and 1,004 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -19,13 +19,15 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install openjdk-8-jre
sudo apt update
sudo apt install proj-bin
sudo apt install openjdk-8-jre
python -m pip install --upgrade pip
python -m pip install poetry
# Only Test Pyspark API for supported Python versions:
if [ "${{ matrix.python-version }}" != "3.10" ]; then echo "Install Pyspark" && poetry add pyspark; fi
poetry install
# Only Test GeoPandas and Pyspark API for supported Python versions:
if [ "${{ matrix.python-version }}" != "3.11" ]; then echo "Install Pyspark" && poetry add pyspark; fi
if [ "${{ matrix.python-version }}" == "3.8" ]; then echo "Install GeoPandas" && poetry add geopandas; fi
- name: Test with pytest
run: |
poetry run pytest --color=yes -s -x -vv --cov-report term-missing --cov=pandas_bokeh Tests/
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ repos:
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 20.8b1
rev: 23.1.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.4.0
hooks:
- id: check-json
- id: check-merge-conflict
Expand Down
4 changes: 3 additions & 1 deletion Release_Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ Plots like scatterplot or histogram also have many more additional customization

* Drop support for Python 3.6
* Rename **plot_height -> height, plot_width -> width** in `pandas_bokeh.plot_grid` interface
* Bugfixes (i.e. fix of lattitude/longitude checking -> thanks @vroger11)
* Bugfixes (thanks @vroger11, @Sigmun, @ToniSkulj)
* Drop support for Python3.8
* Add support for Python3.10 and Python3.11
12 changes: 6 additions & 6 deletions Tests/test_GeoPandasBokeh.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import json
import os
import sys

import geopandas as gpd
import numpy as np
import pandas as pd
import pytest

import pandas_bokeh
Expand All @@ -13,16 +9,20 @@
test_sets_directory = os.path.join(os.path.dirname(directory), "docs", "Testdata")
os.makedirs(os.path.join(directory, "Plots"), exist_ok=True)

# Pyspark requires Python < 3.9:
if sys.version_info < (3, 9):
import geopandas as gpd
else:
pytestmark = pytest.mark.skip


@pytest.fixture
def df_states():

return gpd.read_file(os.path.join(test_sets_directory, "states", "states.geojson"))


@pytest.fixture
def df_cities():

return gpd.read_file(
os.path.join(
test_sets_directory,
Expand Down
11 changes: 2 additions & 9 deletions Tests/test_PandasBokeh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

@pytest.fixture(scope="function")
def df_stock():

np.random.seed(42)
df_stock = pd.DataFrame(
{"Google": np.random.randn(1000) + 0.2, "Apple": np.random.randn(1000) + 0.17},
Expand All @@ -37,7 +36,6 @@ def df_stock():

@pytest.fixture(scope="function")
def df_iris():

# Load Iris Dataset:
df_iris = pd.read_csv(os.path.join(TEST_SETS_DIRECTORY, "iris", "iris.csv"))

Expand All @@ -46,7 +44,6 @@ def df_iris():

@pytest.fixture(scope="function")
def df_fruits():

data = {
"fruits": ["Apples", "Pears", "Nectarines", "Plums", "Grapes", "Strawberries"],
"2015": [2, 1, 4, 3, 2, 4],
Expand All @@ -61,7 +58,6 @@ def df_fruits():

@pytest.fixture(scope="function")
def df_hist():

np.random.seed(42)

df_hist = pd.DataFrame(
Expand All @@ -78,7 +74,6 @@ def df_hist():

@pytest.fixture(scope="function")
def df_energy():

df_energy = pd.read_csv(
os.path.join(TEST_SETS_DIRECTORY, "energy", "energy.csv"), parse_dates=["Year"]
)
Expand All @@ -88,7 +83,6 @@ def df_energy():

@pytest.fixture(scope="function")
def df_election():

df_election = pd.read_csv(
os.path.join(TEST_SETS_DIRECTORY, "Bundestagswahl", "Bundestagswahl.csv")
)
Expand All @@ -98,7 +92,6 @@ def df_election():

@pytest.fixture(scope="function")
def df_mapplot():

df_mapplot = pd.read_csv(
os.path.join(TEST_SETS_DIRECTORY, "populated places", "populated_places.csv")
)
Expand Down Expand Up @@ -279,8 +272,8 @@ def test_pointplot():
"Test for pointplot"

x = np.arange(-3, 3, 0.1)
y2 = x ** 2
y3 = x ** 3
y2 = x**2
y3 = x**3
df = pd.DataFrame({"x": x, "Parabula": y2, "Cube": y3})

arguments = dict(
Expand Down
12 changes: 6 additions & 6 deletions Tests/test_PySpark.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
BASE_DIR = os.path.dirname(__file__)
os.makedirs(os.path.join(BASE_DIR, "Plots"), exist_ok=True)

# Pyspark requires Python < 3.11:
if sys.version_info < (3, 11):
from pyspark.sql import SparkSession
else:
pytestmark = pytest.mark.skip


@pytest.fixture
def spark():
# Start PySpark
from pyspark.sql import SparkSession

spark = SparkSession.builder.getOrCreate()
yield spark
spark.stop()


@pytest.mark.skipif(
sys.version_info >= (3, 10), reason="Pyspark 3.2.1 requires Python <= 3.9"
)
def test_basic_lineplot_pyspark(spark):
"""Test for basic lineplot with Pyspark"""

Expand Down
60 changes: 60 additions & 0 deletions description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Pandas Bokeh

**Pandas Bokeh** provides a [Bokeh](https://bokeh.pydata.org/en/latest/) plotting backend for [Pandas](https://pandas.pydata.org/) and [GeoPandas](http://geopandas.org/), similar to the already existing [Visualization](https://pandas.pydata.org/pandas-docs/stable/visualization.html) feature of Pandas. Importing the library adds a complementary plotting method ***plot_bokeh()*** on **DataFrames** and **Series**. It also has native plotting backend support for Pandas >= 0.25.

For more information and examples have a look at the [Github Repository](https://github.com/PatrikHlobil/Pandas-Bokeh).

---

## Installation


You can install **Pandas Bokeh** from *PyPI* via **pip**:

pip install pandas-bokeh

or *conda*:

conda install -c patrikhlobil pandas-bokeh

**Pandas Bokeh** is officially supported on Python 3.5 and above.

---

## Description

With **Pandas Bokeh**, creating stunning, interactive, HTML-based visualization is as easy as calling:
```python
df.plot_bokeh()
```

The following plot types are supported:

* line
* step
* point
* scatter
* bar
* histogram
* area
* pie
* mapplot

<br>

Furthermore, also **GeoPandas** and **Pyspark** have a new plotting backend as can be seen in the provided [examples](https://github.com/PatrikHlobil/Pandas-Bokeh#geoplots).

<br>

**Pandas Bokeh** is a high-level API for **Bokeh** on top of **Pandas** and **GeoPandas** that tries to figure out best, what the user wants to plot. Nevertheless, there are many options for customizing the plots, for example:

* **figsize**: Choose width & height of the plot
* **title**: Sets title of the plot
* **xlim**/**ylim**: Set visible range of plot for x- and y-axis (also works for *datetime x-axis*)
* **xlabel**/**ylabel**: Set x- and y-labels
* **logx**/**logy**: Set log-scale on x-/y-axis
* **xticks**/**yticks**: Explicitly set the ticks on the axes
* **colormap**: Defines the colors to plot. Can be either a list of colors or the name of a [Bokeh color palette](https://bokeh.pydata.org/en/latest/docs/reference/palettes.html)
* **hovertool_string**: For customization of hovertool content

Each plot type like scatterplot or histogram further has many more additional customization options that is described [here](https://github.com/PatrikHlobil/Pandas-Bokeh).
5 changes: 2 additions & 3 deletions docs/sphinx/source/utils/make_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def df_stocks() -> pd.DataFrame:

def df_parabula_cube() -> pd.DataFrame:
x = np.arange(-3, 3, 0.1)
y2 = x ** 2
y3 = x ** 3
y2 = x**2
y3 = x**3
df = pd.DataFrame({"x": x, "Parabula": y2, "Cube": y3})

return df
Expand Down Expand Up @@ -395,6 +395,5 @@ def _return_plot_functions() -> Callable:


if __name__ == "__main__":

plots = make_and_return_plots()
print(list(plots.keys()))
2 changes: 1 addition & 1 deletion pandas_bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .geoplot import geoplot
from .plot import FramePlotMethods, plot

__version__ = "0.5.5"
__version__ = "0.6.0"


# Register plot_bokeh accessor for Pandas DataFrames and Series:
Expand Down
1 change: 0 additions & 1 deletion pandas_bokeh/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def output_file(filename, title="Bokeh Plot", mode="cdn", root_dir=None):
def show(
obj, browser=None, new="tab", notebook_handle=False, notebook_url="localhost:8888"
):

global SUPPRESS_OUTPUT
if SUPPRESS_OUTPUT:
return obj
Expand Down
2 changes: 0 additions & 2 deletions pandas_bokeh/geoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ def geoplot( # noqa C901
)

if "Polygon" in layertypes:

if "line_color" not in kwargs:
kwargs["line_color"] = "black"

Expand Down Expand Up @@ -723,7 +722,6 @@ def geoplot( # noqa C901

# Add Slider Widget:
if slider is not None:

if slider_range is None:
slider_start = 0
slider_end = len(slider) - 1
Expand Down
Loading

0 comments on commit bb4181c

Please sign in to comment.