0
long =np.array(data.Longitude)
lat = np.array(data.Latitude)
coordinates = np.array(385)
for i in range(385):
    coordinates[i] = np.array([lat[i], long[i]])



#x, y = kmeans2(whiten(coordinates), 3, iter = 20)  
#plt.scatter(coordinates[:,0], coordinates[:,1], c=y);
#plt.show()

I have a dataset with two columns and I wish to merge the latitude and longitude term by term to apply k means clustering after that.Please help with the array part

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pankaj
  • 55
  • 1
  • 8

1 Answers1

1
coordinates = np.array([lat, long])

or am I missing sth here...

SpghttCd
  • 10,510
  • 2
  • 20
  • 25
  • what this does is that it combines (all the lat values as one entry) + ',' + (all the longitude entry).. so effectively i get only one entry in coordinates – Pankaj May 24 '18 at 10:06
  • Hmm - I still don't quite get it, it's a numpy 2D-array, you can index it however you like. And if you're not happy with it you can still transpose it by `.T` – SpghttCd May 24 '18 at 10:36