Package: a-pandas-ex-group-coordinates-by-distance
Group coordinates by euclidean distancefroma_pandas_ex_group_coordinates_by_distanceimportpd_add_group_coordinates_by_distancepd_add_group_coordinates_by_distance()importpandasaspd#first way, from list/tuplecoordinates=[(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)xyitem0745.801086519.85852101747.857483522.50384502747.927307517.12988303750.921143522.30749504756.178101449.87448105757.070312461.23754906757.105774438.67981007759.850159435.39776608761.249390468.02179009764.565857521.395264010770.112732474.639465011770.393372425.349030012773.731262516.653625013776.908447515.535522014778.083557520.688965015779.883606519.207214016782.483887478.808014017784.276184478.511108018797.492920524.435608019800.853882446.971710020801.992249517.873657021802.394714520.419373022804.022583519.916443023809.523315464.247772024813.358459449.658783025830.873962144.218842126819.141235137.673599127825.904541125.727394128826.074585149.3106231291079.317017199.7693792301083.744629151.2262122#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)xyitem0745.801086519.85852101747.857483522.50384502747.927307517.12988303750.921143522.30749504756.178101449.87448105757.070312461.23754906757.105774438.67981007759.850159435.39776608761.249390468.02179009764.565857521.395264010770.112732474.639465011770.393372425.349030012773.731262516.653625013776.908447515.535522014778.083557520.688965015779.883606519.207214016782.483887478.808014017784.276184478.511108018797.492920524.435608019800.853882446.971710020801.992249517.873657021802.394714520.419373022804.022583519.916443023809.523315464.247772024813.358459449.658783025830.873962144.218842126819.141235137.673599127825.904541125.727394128826.074585149.3106231291079.317017199.7693792301083.744629151.2262122