Repository: Zeroto521/my-data-toolkit

Issue:
BUG: `geocentroid`, coordinates should multiply weights
<!--
Thanks for contributing a pull request!

Please follow these standard acronyms to start the commit message:

- ENH: enhancement
- BUG: bug fix
- DOC: documentation
- TYP: type annotations
- TST: addition or modification of tests
- MAINT: maintenance commit (refactoring, typos, etc.)
- BLD: change related to building
- REL: related to releasing
- API: an (incompatible) API change
- DEP: deprecate something, or remove a deprecated object
- DEV: development tool or utility
- REV: revert an earlier commit
- PERF: performance improvement
- BOT: always commit via a bot
- CI: related to CI or CD
- CLN: Code cleanup
-->

- [x] closes #833
- [ ] whatsnew entry



Discussion:
# [Codecov](https://codecov.io/gh/Zeroto521/my-data-toolkit/pull/834?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=40%25) Report
> Merging [#834](https://codecov.io/gh/Zeroto521/my-data-toolkit/pull/834?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=40%25) (3fe698c) into [main](https://codecov.io/gh/Zeroto521/my-data-toolkit/commit/06a046d4aae155e02a6933384fc7d022e8a4f92b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=40%25) (06a046d) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##             main     #834   +/-   ##
=======================================
  Coverage   99.71%   99.71%           
=======================================
  Files         149      149           
  Lines        2089     2089           
  Branches      469      469           
=======================================
  Hits         2083     2083           
  Misses          1        1           
  Partials        5        5           
```


| [Impacted Files](https://codecov.io/gh/Zeroto521/my-data-toolkit/pull/834?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=40%25) | Coverage Δ | |
|---|---|---|
| [dtoolkit/geoaccessor/geoseries/geocentroid.py](https://codecov.io/gh/Zeroto521/my-data-toolkit/pull/834?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=40%25#diff-ZHRvb2xraXQvZ2VvYWNjZXNzb3IvZ2Vvc2VyaWVzL2dlb2NlbnRyb2lkLnB5) | `100.00% <100.00%> (ø)` | |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=40%25)


Resolving patch:
diff --git a/dtoolkit/geoaccessor/geoseries/geocentroid.py b/dtoolkit/geoaccessor/geoseries/geocentroid.py
--- a/dtoolkit/geoaccessor/geoseries/geocentroid.py
+++ b/dtoolkit/geoaccessor/geoseries/geocentroid.py
@@ -80,11 +80,15 @@ def geocentroid(
     <POINT (121.999 54.999)>
     """
 
-    weights = np.asarray(weights) if weights is not None else 1
     coord = xy(s)
+    if len(coord) == 1:
+        return Point(coord.iloc[0])
+
+    weights = np.asarray(weights) if weights is not None else 1
     X = coord.mul(weights, axis=0).mean()
+
     for _ in range(max_iter):
-        dis = geodistance(s, Point(*X.tolist())).rdiv(1).mul(weights, axis=0)
+        dis = geodistance(s, Point(X)).rdiv(1).mul(weights, axis=0)
         Xt = coord.mul(dis, axis=0).sum() / dis.sum()
 
         if ((X - Xt).abs() <= tol).all():
@@ -93,4 +97,4 @@ def geocentroid(
 
         X = Xt
 
-    return Point(*X.tolist())
+    return Point(X)


Test patch:
diff --git a/test/geoaccessor/geoseries/test_geocentroid.py b/test/geoaccessor/geoseries/test_geocentroid.py
new file mode 100644
--- /dev/null
+++ b/test/geoaccessor/geoseries/test_geocentroid.py
@@ -0,0 +1,10 @@
+import geopandas as gpd
+from shapely import Point
+
+from dtoolkit.geoaccessor.geoseries import geocentroid
+
+
+def test_one_point():
+    s = gpd.GeoSeries(Point(100, 32), crs=4326)
+
+    assert geocentroid(s) == Point(100, 32)