Skip to content

Commit

Permalink
Merge pull request #13 from DahnJ/feature/dj-general-upkeep
Browse files Browse the repository at this point in the history
Feature/dj general upkeep
  • Loading branch information
DahnJ authored Feb 15, 2022
2 parents f3f80de + 0b0ff01 commit efa450e
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[codespell]
skip = *.ipynb
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ repos:
hooks:
- id: flake8
language_version: python3

- repo: https://github.com/codespell-project/codespell
rev: v1.16.0
hooks:
- id: codespell
language_version: python3
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ and [Pandas](https://github.com/pandas-dev/pandas).
## Installation
### pip
[![image](https://img.shields.io/pypi/v/h3pandas.svg)](https://pypi.python.org/pypi/h3pandas)
[![image](https://pepy.tech/badge/h3pandas)](https://pepy.tech/project/h3pandas)
```bash
pip install h3pandas
```
Expand Down Expand Up @@ -119,13 +118,16 @@ For a full API documentation and more usage examples, see the
[documentation](https://h3-pandas.readthedocs.io/en/latest/).

## Development
This package is under active development, **suggestions and contributions are very welcome**!
H3-Pandas cover the basics of the H3 API, but there are still many possible improvements.

**Any suggestions and contributions are very welcome**!

In particular, the next steps are:
- [ ] Improve documentation, examples
- [ ] Greater coverage of the H3 API
- [ ] Improvements & stability of the "Extended API", e.g. `k_ring_smoothing`.

Additional possible directions
- [ ] Allow for alternate h3-py APIs such as [memview_int](https://github.com/uber/h3-py#h3apimemview_int)
- [ ] Performance improvements through [Cythonized h3-py](https://github.com/uber/h3-py/pull/147)
- [ ] [Dask](https://github.com/dask/dask) integration trough [dask-geopandas](https://github.com/geopandas/dask-geopandas) (experimental as of now)
- [ ] [Dask](https://github.com/dask/dask) integration through [dask-geopandas](https://github.com/geopandas/dask-geopandas) (experimental as of now)

See [issues](https://github.com/DahnJ/H3-Pandas/issues) for more.
13 changes: 10 additions & 3 deletions docs/source/notebook/00-intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@
"We can use `geo_to_h3` to add an index with H3 addresses resolution 10"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`geo_to_h3` assumes coordinates are in `epsg=4326`"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -247,7 +254,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For now, we will pretend H3-Pandas do not have [aggregation functions](#Aggregation-functions) and perform the aggregations manually"
"For now, we will pretend H3-Pandas does not have [aggregation functions](#Aggregation-functions) and perform the aggregations manually"
]
},
{
Expand Down Expand Up @@ -649,7 +656,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Aggregation functions: The same workflow, streamlined"
"## H3-Pandas Extended API: The same workflow, streamlined"
]
},
{
Expand Down Expand Up @@ -705,7 +712,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down
69 changes: 48 additions & 21 deletions docs/source/notebook/01-unified-data-layers.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- python=3.9
- shapely
- h3-py=3.7.*
- geopandas=0.9.*
- geopandas>=0.9.*
- pandas
# For Python <3.8
# - typing_extensions
Expand Down
10 changes: 6 additions & 4 deletions h3pandas/h3pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def geo_to_h3(
pd.DataFrame: uses `lat_col` and `lng_col` (default `lat` and `lng`)
gpd.GeoDataFrame: uses `geometry`
Assumes coordinates in epsg=4326.
Parameters
----------
resolution : int
Expand Down Expand Up @@ -255,7 +257,7 @@ def k_ring(self, k: int = 1, explode: bool = False) -> AnyDataFrame:
func = wrapped_partial(h3.k_ring, k=k)
column_name = "h3_k_ring"
if explode:
return self.__apply_index_explode(func, column_name, list)
return self._apply_index_explode(func, column_name, list)
return self._apply_index_assign(func, column_name, list)

@doc_standard(
Expand Down Expand Up @@ -300,7 +302,7 @@ def hex_ring(self, k: int = 1, explode: bool = False) -> AnyDataFrame:
func = wrapped_partial(h3.hex_ring, k=k)
column_name = "h3_hex_ring"
if explode:
return self.__apply_index_explode(func, column_name, list)
return self._apply_index_explode(func, column_name, list)
return self._apply_index_assign(func, column_name, list)

@doc_standard("h3_{resolution}", "containing the parent of each H3 address")
Expand Down Expand Up @@ -668,7 +670,7 @@ def k_ring_smoothing(

# Unweighted case
if weights is None:
result = (
result = pd.DataFrame(
self._df.h3.k_ring(k, explode=True)
.groupby("h3_k_ring")
.sum()
Expand Down Expand Up @@ -788,7 +790,7 @@ def _apply_index_assign(
assign_args = {column_name: result}
return finalizer(self._df.assign(**assign_args))

def __apply_index_explode(
def _apply_index_explode(
self,
func: Callable,
column_name: str,
Expand Down
9 changes: 8 additions & 1 deletion notebook/00-intro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@
"We can use `geo_to_h3` to add an index with H3 addresses resolution 10"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`geo_to_h3` assumes coordinates are in `epsg=4326`"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -705,7 +712,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion notebook/01-unified-data-layers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down

0 comments on commit efa450e

Please sign in to comment.