Skip to main content

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

Metadata

Release files for a-pandas-ex-group-coordinates-by-distance 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a-pandas-ex-group-coordinates-by-distance 0.10
File Size Uploaded Provenance Actions
a_pandas_ex_group_coordinates_by_distance-0.10.tar.gz 6.3 kB Without provenance Details for a_pandas_ex_group_coordinates_by_distance-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for a-pandas-ex-group-coordinates-by-distance 0.10
File Interpreter ABI Platform Actions
a_pandas_ex_group_coordinates_by_distance-0.10-py3-none-any.whl Python 3 none any Details for a_pandas_ex_group_coordinates_by_distance-0.10-py3-none-any.whl

Total release size: 14.9 kB

Release files / a_pandas_ex_group_coordinates_by_distance-0.10.tar.gz

Download URL a_pandas_ex_group_coordinates_by_distance-0.10.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
02f03b71b570dfe47d13c23b64c58f8187ce4c53319299cc70d630fc8b2283a7
BLAKE2b-256 checksum
How to use checksums
2f518486fe2d72760cae1ad3099f230580d23600eefa0ce762d242fa37e9984c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / a_pandas_ex_group_coordinates_by_distance-0.10-py3-none-any.whl

Download URL a_pandas_ex_group_coordinates_by_distance-0.10-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88f8a066a87b3217b66a5b3b745c16ea0a2eac009264a2ccfb7241bc8df555e3
BLAKE2b-256 checksum
How to use checksums
ed77bcefc65b940ebc9c1929c11cbcf544c6221ec9a072674eb7b854026865f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for a-pandas-ex-group-coordinates-by-distance 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page