i have this kind of csv data
i want to show them with matplotlib like this figure
with latitude and longitude as x and y.
this is my code
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.model_selection import train_test_split
from matplotlib.colors import ListedColormap
cmap = ListedColormap(['#FF0000','#00FF00','#0000FF'])
df = pd.DataFrame(data)
X = df.drop(['Wisata','Link Gambar','Nama','Region'],axis = 1) #this left with only latitude and #longitude
y = df['Wisata'] #this is the label
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size = 0.2,random_state=1)
i've tried this but it doesn't work
plt.figure()
plt.scatter(X[:,0],X[:,1],c=y,cmap=cmap,edgecolors='k',s=20)
plt.show()
it gives this error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3628 try:
-> 3629 return self._engine.get_loc(casted_key)
3630 except KeyError as err:
D:\Anaconda\lib\site-packages\pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
D:\Anaconda\lib\site-packages\pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: '(slice(None, None, None), 0)' is an invalid key
During handling of the above exception, another exception occurred:
InvalidIndexError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_12876\2344342603.py in <module>
1 plt.figure()
----> 2 plt.scatter(X[:,0],X[:,1],c=y,cmap=cmap,edgecolors='k',s=20)
3 plt.show()
D:\Anaconda\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
3503 if self.columns.nlevels > 1:
3504 return self._getitem_multilevel(key)
-> 3505 indexer = self.columns.get_loc(key)
3506 if is_integer(indexer):
3507 indexer = [indexer]
D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3634 # InvalidIndexError. Otherwise we fall through and re-raise
3635 # the TypeError.
-> 3636 self._check_indexing_error(key)
3637 raise
3638
D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py in _check_indexing_error(self, key)
5649 # if key is not a scalar, directly raise an error (the code below
5650 # would convert to numpy arrays and raise later any way) - GH29926
-> 5651 raise InvalidIndexError(key)
5652
5653 @cache_readonly
InvalidIndexError: (slice(None, None, None), 0)
<Figure size 640x480 with 0 Axes>
im still new to python and can't read the error and fix it because the error is so long.. any suggestions how to fix it?