Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lovasoa/kdsearch
Search k-dimensional datasets efficiently using KDTrees
https://github.com/lovasoa/kdsearch
kd-tree numpy pandas python3 scipy
Last synced: 3 months ago
JSON representation
Search k-dimensional datasets efficiently using KDTrees
- Host: GitHub
- URL: https://github.com/lovasoa/kdsearch
- Owner: lovasoa
- License: gpl-3.0
- Created: 2017-03-01T21:20:13.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-03T14:03:27.000Z (almost 8 years ago)
- Last Synced: 2024-09-30T22:01:24.147Z (3 months ago)
- Topics: kd-tree, numpy, pandas, python3, scipy
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KDSearch
Efficient K-dimensional queries in python using KDTrees with pandas and numpy.
[![Build Status](https://travis-ci.org/lovasoa/kdsearch.svg?branch=master)](https://travis-ci.org/lovasoa/kdsearch)
## Requirements
- python 3.5+
- numpy
- pandas## Installation
To install this package for the current user:
```
pip3 install --user kdsearch
```## example
```python
import pandas
from kdsearch import KDTree# We create a dataset with three points (1,3), (2,3) and (3,4)
df = pandas.DataFrame({"x": [1,2,3], "y":[3,3,4], "target": [0,1,1]})
tree = KDTree(df, ('x','y'), 'target')
## Query all points with x between 0 and 10 and y between 0 and 3 (inclusive)
tree.query({"x":[0,10], "y":[0,3]})
# Statistics(sum=1, length=2)tree.query({"x":[0,10], "y":[0,10]})
# Statistics(sum=2, length=3)tree.query({"x":[5,10], "y":[5,10]})
# Statistics(sum=0, length=0)
```