Group coordinates by euclidean distance
Project description
Group coordinates by euclidean distance
from a_pandas_ex_group_coordinates_by_distance import pd_add_group_coordinates_by_distance
pd_add_group_coordinates_by_distance()
import pandas as pd
#first way, from list/tuple
coordinates = [(745.8010864257812, 519.8585205078125),
(747.8574829101562, 522.5038452148438),
(747.9273071289062, 517.1298828125),
(747.9273071289062, 517.1298828125),
(750.921142578125, 522.3074951171875),
(756.1781005859375, 449.8744812011719),
(757.0703125, 461.237548828125),
(757.0703125, 461.237548828125),
(757.1057739257812, 438.6798095703125),
(830.8739624023438, 144.21884155273438),
(759.8501586914062, 435.39776611328125),
(759.8501586914062, 435.39776611328125),
(761.2493896484375, 468.02178955078125),
(761.2493896484375, 468.02178955078125),
(764.5658569335938, 521.395263671875),
(1079.3170166015625, 199.76937866210938),
(770.1127319335938, 474.63946533203125),
(770.3933715820312, 425.3490295410156),
(773.7312622070312, 516.6536254882812),
(776.908447265625, 515.5355224609375),
(776.908447265625, 515.5355224609375),
(778.0835571289062, 520.68896484375),
(779.8836059570312, 519.2072143554688),
(780.3491821289062, 420.33465576171875),
(780.3491821289062, 420.33465576171875),
(782.48388671875, 478.8080139160156),
(782.48388671875, 478.8080139160156),
(1083.74462890625, 151.22621154785156),
(1083.74462890625, 151.22621154785156),
(1083.74462890625, 151.22621154785156),
(1083.74462890625, 151.22621154785156),
(784.2761840820312, 478.5111083984375),
(759.8501586914062, 435.39776611328125),
(784.2761840820312, 478.5111083984375),
(819.1412353515625, 137.67359924316406),
(819.1412353515625, 137.67359924316406),
(819.1412353515625, 137.67359924316406),
(797.492919921875, 524.4356079101562),
(825.904541015625, 125.7273941040039),
(826.0745849609375, 149.3106231689453),
(800.8538818359375, 446.9717102050781),
(800.8538818359375, 446.9717102050781),
(801.9922485351562, 517.8736572265625),
(801.9922485351562, 517.8736572265625),
(802.3947143554688, 520.4193725585938),
(802.3947143554688, 520.4193725585938),
(804.0225830078125, 519.9164428710938),
(804.0225830078125, 519.9164428710938),
(808.3038940429688, 431.790771484375),
(808.3038940429688, 431.790771484375),
(809.5233154296875, 464.2477722167969),
(809.5233154296875, 464.2477722167969),
(812.5013427734375, 438.7483825683594),
(813.3584594726562, 449.6587829589844)]
df=pd.Q_group_coordinates_by_distance_df(coordinates=coordinates,max_euclidean_distance=100)
print(df)
x y item
0 745.801086 519.858521 0
1 747.857483 522.503845 0
2 747.927307 517.129883 0
3 750.921143 522.307495 0
4 756.178101 449.874481 0
5 757.070312 461.237549 0
6 757.105774 438.679810 0
7 759.850159 435.397766 0
8 761.249390 468.021790 0
9 764.565857 521.395264 0
10 770.112732 474.639465 0
11 770.393372 425.349030 0
12 773.731262 516.653625 0
13 776.908447 515.535522 0
14 778.083557 520.688965 0
15 779.883606 519.207214 0
16 782.483887 478.808014 0
17 784.276184 478.511108 0
18 797.492920 524.435608 0
19 800.853882 446.971710 0
20 801.992249 517.873657 0
21 802.394714 520.419373 0
22 804.022583 519.916443 0
23 809.523315 464.247772 0
24 813.358459 449.658783 0
25 830.873962 144.218842 1
26 819.141235 137.673599 1
27 825.904541 125.727394 1
28 826.074585 149.310623 1
29 1079.317017 199.769379 2
30 1083.744629 151.226212 2
#second way, directly from DataFrame with 2 columns (column names don't matter, just the right order (x,y))
df2=pd.DataFrame(coordinates)
df3=df2.d_group_coordinates_by_distance_df(max_euclidean_distance=100)
print(df3)
x y item
0 745.801086 519.858521 0
1 747.857483 522.503845 0
2 747.927307 517.129883 0
3 750.921143 522.307495 0
4 756.178101 449.874481 0
5 757.070312 461.237549 0
6 757.105774 438.679810 0
7 759.850159 435.397766 0
8 761.249390 468.021790 0
9 764.565857 521.395264 0
10 770.112732 474.639465 0
11 770.393372 425.349030 0
12 773.731262 516.653625 0
13 776.908447 515.535522 0
14 778.083557 520.688965 0
15 779.883606 519.207214 0
16 782.483887 478.808014 0
17 784.276184 478.511108 0
18 797.492920 524.435608 0
19 800.853882 446.971710 0
20 801.992249 517.873657 0
21 802.394714 520.419373 0
22 804.022583 519.916443 0
23 809.523315 464.247772 0
24 813.358459 449.658783 0
25 830.873962 144.218842 1
26 819.141235 137.673599 1
27 825.904541 125.727394 1
28 826.074585 149.310623 1
29 1079.317017 199.769379 2
30 1083.744629 151.226212 2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file a_pandas_ex_group_coordinates_by_distance-0.10.tar.gz
.
File metadata
- Download URL: a_pandas_ex_group_coordinates_by_distance-0.10.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02f03b71b570dfe47d13c23b64c58f8187ce4c53319299cc70d630fc8b2283a7 |
|
MD5 | c8e839094993c8dd36d49ef543fbb0bf |
|
BLAKE2b-256 | 2f518486fe2d72760cae1ad3099f230580d23600eefa0ce762d242fa37e9984c |
File details
Details for the file a_pandas_ex_group_coordinates_by_distance-0.10-py3-none-any.whl
.
File metadata
- Download URL: a_pandas_ex_group_coordinates_by_distance-0.10-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88f8a066a87b3217b66a5b3b745c16ea0a2eac009264a2ccfb7241bc8df555e3 |
|
MD5 | 7691e7849ee0663c36c2aed4d8bf159a |
|
BLAKE2b-256 | ed77bcefc65b940ebc9c1929c11cbcf544c6221ec9a072674eb7b854026865f7 |