'Error when plotting with geoseries in a shapefile

I´m trying to plot my Kmean clustering in a shapefile from my city, but I keep getting an error with Geoseries my code

    km = MiniBatchKMeans(n_clusters=i)
km.fit_predict(df_pickup)

# Label cluster centers
centers = km.cluster_centers_

# Calculate sum of squared distances
ssd.append(km.inertia_)

# Get cluster center
df_pickup['cluster'] = km.labels_

geo_df = gpd.GeoDataFrame(df_pickup.drop(['longitud','latitud'],axis=1), 
geometry=gpd.points_from_xy(x=df_pickup.longitud, y=df_pickup.latitud)) 

centers_gseries = GeoSeries(map(Point, zip(centers[:,1], centers[:,0])))
centers_gseries.plot(ax=ax, alpha=1, marker='X', color='red', markersize=100, zorder=3)

The error

---> 41     centers_gseries = GeoSeries(map(Point, zip(centers[:,1], centers[:,0])))
TypeError: __init__() missing 1 required positional argument: 'y'

I´m passing my two coordinates so I don´t know why It gives me that error



Solution 1:[1]

Use a built-in method to create points instead.

centers_gseries = GeoSeries.from_xy(centers[:,1], centers[:,0])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 martinfleis