{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"![tcs_1x](https://user-images.githubusercontent.com/50532530/121583757-47745c00-ca4e-11eb-927f-84e256e28f6a.jpeg)","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-06-04T11:54:05.618259Z","iopub.execute_input":"2021-06-04T11:54:05.618866Z","iopub.status.idle":"2021-06-04T11:54:27.33766Z","shell.execute_reply.started":"2021-06-04T11:54:05.618773Z","shell.execute_reply":"2021-06-04T11:54:27.33658Z"}}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.cluster import DBSCAN\nfrom geopy.distance import great_circle\nfrom shapely.geometry import MultiPoint\nfrom shapely.geometry import Point\nimport geopandas as gpd\nfrom geopandas import GeoDataFrame\n","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:27.339226Z","iopub.execute_input":"2021-06-04T11:54:27.339531Z","iopub.status.idle":"2021-06-04T11:54:29.816708Z","shell.execute_reply.started":"2021-06-04T11:54:27.339501Z","shell.execute_reply":"2021-06-04T11:54:29.815636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/birdclef-2021/train_metadata.csv')\ndf","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:29.819062Z","iopub.execute_input":"2021-06-04T11:54:29.819687Z","iopub.status.idle":"2021-06-04T11:54:30.572925Z","shell.execute_reply.started":"2021-06-04T11:54:29.81963Z","shell.execute_reply":"2021-06-04T11:54:30.57194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#df['date_new']=df.date.str[:4]","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.574674Z","iopub.execute_input":"2021-06-04T11:54:30.575239Z","iopub.status.idle":"2021-06-04T11:54:30.57955Z","shell.execute_reply.started":"2021-06-04T11:54:30.575193Z","shell.execute_reply":"2021-06-04T11:54:30.578664Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#df.drop(['date'],axis=1,inplace = True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.581134Z","iopub.execute_input":"2021-06-04T11:54:30.58165Z","iopub.status.idle":"2021-06-04T11:54:30.59367Z","shell.execute_reply.started":"2021-06-04T11:54:30.581605Z","shell.execute_reply":"2021-06-04T11:54:30.59231Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#X = df.iloc[:,3:].values\n#X","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.595302Z","iopub.execute_input":"2021-06-04T11:54:30.596052Z","iopub.status.idle":"2021-06-04T11:54:30.606829Z","shell.execute_reply.started":"2021-06-04T11:54:30.595962Z","shell.execute_reply":"2021-06-04T11:54:30.60523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx = pd.DataFrame(X, columns = ['latitude','longitude','scientific_name','common_name','author','filename','license','rating','time','url'])\n\n","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.608658Z","iopub.execute_input":"2021-06-04T11:54:30.60915Z","iopub.status.idle":"2021-06-04T11:54:30.619499Z","shell.execute_reply.started":"2021-06-04T11:54:30.609103Z","shell.execute_reply":"2021-06-04T11:54:30.618456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['filename'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.621958Z","iopub.execute_input":"2021-06-04T11:54:30.622421Z","iopub.status.idle":"2021-06-04T11:54:30.630055Z","shell.execute_reply.started":"2021-06-04T11:54:30.622375Z","shell.execute_reply":"2021-06-04T11:54:30.629072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['license'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.631841Z","iopub.execute_input":"2021-06-04T11:54:30.632312Z","iopub.status.idle":"2021-06-04T11:54:30.64369Z","shell.execute_reply.started":"2021-06-04T11:54:30.632267Z","shell.execute_reply":"2021-06-04T11:54:30.64259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['rating'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.645056Z","iopub.execute_input":"2021-06-04T11:54:30.64555Z","iopub.status.idle":"2021-06-04T11:54:30.655368Z","shell.execute_reply.started":"2021-06-04T11:54:30.645509Z","shell.execute_reply":"2021-06-04T11:54:30.654534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['time'],axis=1,inplace=True)\n#dx.drop(['url'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.656824Z","iopub.execute_input":"2021-06-04T11:54:30.657149Z","iopub.status.idle":"2021-06-04T11:54:30.667552Z","shell.execute_reply.started":"2021-06-04T11:54:30.657118Z","shell.execute_reply":"2021-06-04T11:54:30.666624Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['scientific_name'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.66936Z","iopub.execute_input":"2021-06-04T11:54:30.669958Z","iopub.status.idle":"2021-06-04T11:54:30.681884Z","shell.execute_reply.started":"2021-06-04T11:54:30.669911Z","shell.execute_reply":"2021-06-04T11:54:30.680862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['common_name'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.683362Z","iopub.execute_input":"2021-06-04T11:54:30.683688Z","iopub.status.idle":"2021-06-04T11:54:30.694438Z","shell.execute_reply.started":"2021-06-04T11:54:30.683655Z","shell.execute_reply":"2021-06-04T11:54:30.693393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['author'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.69615Z","iopub.execute_input":"2021-06-04T11:54:30.696464Z","iopub.status.idle":"2021-06-04T11:54:30.70793Z","shell.execute_reply.started":"2021-06-04T11:54:30.69643Z","shell.execute_reply":"2021-06-04T11:54:30.706909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['date_new'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.709153Z","iopub.execute_input":"2021-06-04T11:54:30.709443Z","iopub.status.idle":"2021-06-04T11:54:30.722991Z","shell.execute_reply.started":"2021-06-04T11:54:30.709414Z","shell.execute_reply":"2021-06-04T11:54:30.721789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx['latitude'] = dx['latitude'].astype(float)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.724204Z","iopub.execute_input":"2021-06-04T11:54:30.724528Z","iopub.status.idle":"2021-06-04T11:54:30.735289Z","shell.execute_reply.started":"2021-06-04T11:54:30.724496Z","shell.execute_reply":"2021-06-04T11:54:30.734068Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx['longitude'] = dx['longitude'].astype(float)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.73675Z","iopub.execute_input":"2021-06-04T11:54:30.737206Z","iopub.status.idle":"2021-06-04T11:54:30.746373Z","shell.execute_reply.started":"2021-06-04T11:54:30.737156Z","shell.execute_reply":"2021-06-04T11:54:30.745391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#geometry = [Point(xy) for xy in zip(df['longitude'], df['latitude'])]\n#gdf = GeoDataFrame(dx, geometry=geometry)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.747764Z","iopub.execute_input":"2021-06-04T11:54:30.748344Z","iopub.status.idle":"2021-06-04T11:54:30.760821Z","shell.execute_reply.started":"2021-06-04T11:54:30.748308Z","shell.execute_reply":"2021-06-04T11:54:30.759932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nfrom sklearn.cluster import KMeans","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.762383Z","iopub.execute_input":"2021-06-04T11:54:30.762971Z","iopub.status.idle":"2021-06-04T11:54:30.772184Z","shell.execute_reply.started":"2021-06-04T11:54:30.762929Z","shell.execute_reply":"2021-06-04T11:54:30.771073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['date_new'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.773496Z","iopub.execute_input":"2021-06-04T11:54:30.773771Z","iopub.status.idle":"2021-06-04T11:54:30.782621Z","shell.execute_reply.started":"2021-06-04T11:54:30.773746Z","shell.execute_reply":"2021-06-04T11:54:30.781826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['geometry'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.783924Z","iopub.execute_input":"2021-06-04T11:54:30.784421Z","iopub.status.idle":"2021-06-04T11:54:30.79301Z","shell.execute_reply.started":"2021-06-04T11:54:30.784375Z","shell.execute_reply":"2021-06-04T11:54:30.792227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.drop(['cluster_label'],axis=1,inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.794201Z","iopub.execute_input":"2021-06-04T11:54:30.794691Z","iopub.status.idle":"2021-06-04T11:54:30.804262Z","shell.execute_reply.started":"2021-06-04T11:54:30.794649Z","shell.execute_reply":"2021-06-04T11:54:30.803342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.807917Z","iopub.execute_input":"2021-06-04T11:54:30.808476Z","iopub.status.idle":"2021-06-04T11:54:30.814879Z","shell.execute_reply.started":"2021-06-04T11:54:30.808424Z","shell.execute_reply":"2021-06-04T11:54:30.814118Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"coords = df[['longitude', 'latitude']].to_numpy()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.816665Z","iopub.execute_input":"2021-06-04T11:54:30.817094Z","iopub.status.idle":"2021-06-04T11:54:30.830305Z","shell.execute_reply.started":"2021-06-04T11:54:30.817056Z","shell.execute_reply":"2021-06-04T11:54:30.829311Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"coords","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.831661Z","iopub.execute_input":"2021-06-04T11:54:30.831936Z","iopub.status.idle":"2021-06-04T11:54:30.844569Z","shell.execute_reply.started":"2021-06-04T11:54:30.831908Z","shell.execute_reply":"2021-06-04T11:54:30.84356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#dx.plot.scatter(x = 'latitude', y = 'longitude', c=labels, s=15, cmap='viridis')\n#plt.scatter(centers[:, 0], c='black', s=200, alpha=0.5)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.846105Z","iopub.execute_input":"2021-06-04T11:54:30.846632Z","iopub.status.idle":"2021-06-04T11:54:30.853771Z","shell.execute_reply.started":"2021-06-04T11:54:30.846588Z","shell.execute_reply":"2021-06-04T11:54:30.853065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#!pip install folium","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.855027Z","iopub.execute_input":"2021-06-04T11:54:30.855575Z","iopub.status.idle":"2021-06-04T11:54:30.863301Z","shell.execute_reply.started":"2021-06-04T11:54:30.855529Z","shell.execute_reply":"2021-06-04T11:54:30.862365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib\n%matplotlib inline\n%config InlineBackend.figure_format = 'svg'\nimport matplotlib.pyplot as plt\nplt.style.use('ggplot')\n\nimport pandas as pd\nimport numpy as np\nimport seaborn as sns\nfrom tqdm import tqdm\nfrom sklearn.cluster import KMeans, DBSCAN\nfrom sklearn.metrics import silhouette_score\nfrom sklearn.datasets import make_blobs\nfrom sklearn.neighbors import KNeighborsClassifier\nfrom ipywidgets import interactive\nfrom collections import defaultdict\n#import hdbscan\nimport folium\nimport re","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:30.864502Z","iopub.execute_input":"2021-06-04T11:54:30.864812Z","iopub.status.idle":"2021-06-04T11:54:31.242905Z","shell.execute_reply.started":"2021-06-04T11:54:30.864781Z","shell.execute_reply":"2021-06-04T11:54:31.241873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#sns.scatterplot(x=dx['latitude'], y = dx['longitude'])","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:31.244078Z","iopub.execute_input":"2021-06-04T11:54:31.244368Z","iopub.status.idle":"2021-06-04T11:54:31.248165Z","shell.execute_reply.started":"2021-06-04T11:54:31.244337Z","shell.execute_reply":"2021-06-04T11:54:31.246942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"db = DBSCAN(eps=0.6, min_samples=1).fit(coords)\ncore_samples_mask = np.zeros_like(db.labels_, dtype=bool)\ncore_samples_mask[db.core_sample_indices_] = True\nlabels = db.labels_","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:31.249453Z","iopub.execute_input":"2021-06-04T11:54:31.249733Z","iopub.status.idle":"2021-06-04T11:54:32.739195Z","shell.execute_reply.started":"2021-06-04T11:54:31.249705Z","shell.execute_reply":"2021-06-04T11:54:32.738189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:32.740782Z","iopub.execute_input":"2021-06-04T11:54:32.74118Z","iopub.status.idle":"2021-06-04T11:54:32.747432Z","shell.execute_reply.started":"2021-06-04T11:54:32.741138Z","shell.execute_reply":"2021-06-04T11:54:32.746346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_clusters_ = len(set(labels)) - (1 if -1 in labels else 0)\nn_noise_ = list(labels).count(-1)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:32.748627Z","iopub.execute_input":"2021-06-04T11:54:32.748889Z","iopub.status.idle":"2021-06-04T11:54:32.788258Z","shell.execute_reply.started":"2021-06-04T11:54:32.748863Z","shell.execute_reply":"2021-06-04T11:54:32.786984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_clusters_","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:32.789687Z","iopub.execute_input":"2021-06-04T11:54:32.789979Z","iopub.status.idle":"2021-06-04T11:54:32.803371Z","shell.execute_reply.started":"2021-06-04T11:54:32.78995Z","shell.execute_reply":"2021-06-04T11:54:32.802588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_noise_","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:32.804571Z","iopub.execute_input":"2021-06-04T11:54:32.804883Z","iopub.status.idle":"2021-06-04T11:54:32.818151Z","shell.execute_reply.started":"2021-06-04T11:54:32.80485Z","shell.execute_reply":"2021-06-04T11:54:32.816975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neighbors import NearestNeighbors\nfrom matplotlib import pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:32.82122Z","iopub.execute_input":"2021-06-04T11:54:32.8216Z","iopub.status.idle":"2021-06-04T11:54:32.833489Z","shell.execute_reply.started":"2021-06-04T11:54:32.821565Z","shell.execute_reply":"2021-06-04T11:54:32.832639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"neighbors = NearestNeighbors(n_neighbors=20)\nneighbors_fit = neighbors.fit(coords)\ndistances, indices = neighbors_fit.kneighbors(coords)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:32.836634Z","iopub.execute_input":"2021-06-04T11:54:32.837345Z","iopub.status.idle":"2021-06-04T11:54:33.147764Z","shell.execute_reply.started":"2021-06-04T11:54:32.837291Z","shell.execute_reply":"2021-06-04T11:54:33.146454Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"distances = np.sort(distances, axis=0)\ndistances = distances[:,1]\nplt.plot(distances)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:33.149279Z","iopub.execute_input":"2021-06-04T11:54:33.149597Z","iopub.status.idle":"2021-06-04T11:54:33.407246Z","shell.execute_reply.started":"2021-06-04T11:54:33.149564Z","shell.execute_reply":"2021-06-04T11:54:33.40618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"n_noise_","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:33.408517Z","iopub.execute_input":"2021-06-04T11:54:33.408812Z","iopub.status.idle":"2021-06-04T11:54:33.412818Z","shell.execute_reply.started":"2021-06-04T11:54:33.408784Z","shell.execute_reply":"2021-06-04T11:54:33.412162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#import sklearn.metrics as metrics","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:33.413867Z","iopub.execute_input":"2021-06-04T11:54:33.414255Z","iopub.status.idle":"2021-06-04T11:54:33.426183Z","shell.execute_reply.started":"2021-06-04T11:54:33.414217Z","shell.execute_reply":"2021-06-04T11:54:33.425154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:33.427477Z","iopub.execute_input":"2021-06-04T11:54:33.42775Z","iopub.status.idle":"2021-06-04T11:54:33.440028Z","shell.execute_reply.started":"2021-06-04T11:54:33.427723Z","shell.execute_reply":"2021-06-04T11:54:33.439006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"unique_labels = set(labels)\ncolors = [plt.get_cmap('Spectral')(each)\n          for each in np.linspace(0, 1, len(unique_labels))]\nfor k, col in zip(unique_labels, colors):\n    if k == -1:\n        # Black used for noise.\n        col = [0, 0, 0, 1]\n\n    class_member_mask = (labels == k)\n\n    xy = coords[class_member_mask & core_samples_mask]\n    plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col),\n             markeredgecolor='k', markersize=14)\n\n    xy = coords[class_member_mask & ~core_samples_mask]\n    plt.plot(xy[:, 0], xy[:, 1], 'o', markerfacecolor=tuple(col),\n             markeredgecolor='k', markersize=6)\n\nplt.title('Estimated number of clusters: %d' % n_clusters_)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:33.441325Z","iopub.execute_input":"2021-06-04T11:54:33.441586Z","iopub.status.idle":"2021-06-04T11:54:40.941385Z","shell.execute_reply.started":"2021-06-04T11:54:33.44156Z","shell.execute_reply":"2021-06-04T11:54:40.940193Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install reverse-geocode","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:40.94276Z","iopub.execute_input":"2021-06-04T11:54:40.943101Z","iopub.status.idle":"2021-06-04T11:54:51.765141Z","shell.execute_reply.started":"2021-06-04T11:54:40.943064Z","shell.execute_reply":"2021-06-04T11:54:51.763888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import reverse_geocode as rg\ncoordinates = coords\nu = rg.search(coordinates)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:51.768985Z","iopub.execute_input":"2021-06-04T11:54:51.769339Z","iopub.status.idle":"2021-06-04T11:54:52.357156Z","shell.execute_reply.started":"2021-06-04T11:54:51.769305Z","shell.execute_reply":"2021-06-04T11:54:52.356105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"u[0]","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.358639Z","iopub.execute_input":"2021-06-04T11:54:52.358965Z","iopub.status.idle":"2021-06-04T11:54:52.367043Z","shell.execute_reply.started":"2021-06-04T11:54:52.35893Z","shell.execute_reply":"2021-06-04T11:54:52.365701Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.DataFrame(u)\npd.DataFrame.from_dict(u)\nbc = pd.DataFrame.from_records(u)","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.368908Z","iopub.execute_input":"2021-06-04T11:54:52.369351Z","iopub.status.idle":"2021-06-04T11:54:52.500228Z","shell.execute_reply.started":"2021-06-04T11:54:52.369301Z","shell.execute_reply":"2021-06-04T11:54:52.49914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bc","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.503197Z","iopub.execute_input":"2021-06-04T11:54:52.503575Z","iopub.status.idle":"2021-06-04T11:54:52.520983Z","shell.execute_reply.started":"2021-06-04T11:54:52.503539Z","shell.execute_reply":"2021-06-04T11:54:52.519975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"res2 = pd.concat([df,bc], axis=1, join='inner')\nres2","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.522275Z","iopub.execute_input":"2021-06-04T11:54:52.522572Z","iopub.status.idle":"2021-06-04T11:54:52.58103Z","shell.execute_reply.started":"2021-06-04T11:54:52.522541Z","shell.execute_reply":"2021-06-04T11:54:52.580156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.582229Z","iopub.execute_input":"2021-06-04T11:54:52.58251Z","iopub.status.idle":"2021-06-04T11:54:52.587761Z","shell.execute_reply.started":"2021-06-04T11:54:52.582482Z","shell.execute_reply":"2021-06-04T11:54:52.586958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"temp = pd.DataFrame(labels, columns = ['Cluster_point'])\n","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.588892Z","iopub.execute_input":"2021-06-04T11:54:52.589368Z","iopub.status.idle":"2021-06-04T11:54:52.602246Z","shell.execute_reply.started":"2021-06-04T11:54:52.589315Z","shell.execute_reply":"2021-06-04T11:54:52.601124Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_train_meta = pd.concat([res2,temp], axis=1, join='inner')\nfinal_train_meta","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.603481Z","iopub.execute_input":"2021-06-04T11:54:52.603967Z","iopub.status.idle":"2021-06-04T11:54:52.682874Z","shell.execute_reply.started":"2021-06-04T11:54:52.603917Z","shell.execute_reply":"2021-06-04T11:54:52.682106Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_train_meta.to_csv('alter_meta_3.csv')","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:52.684023Z","iopub.execute_input":"2021-06-04T11:54:52.684464Z","iopub.status.idle":"2021-06-04T11:54:53.355346Z","shell.execute_reply.started":"2021-06-04T11:54:52.68442Z","shell.execute_reply":"2021-06-04T11:54:53.354187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"z = pd.read_csv('./alter_meta_3.csv')","metadata":{"execution":{"iopub.status.busy":"2021-06-04T11:54:53.357198Z","iopub.execute_input":"2021-06-04T11:54:53.357699Z","iopub.status.idle":"2021-06-04T11:54:53.814156Z","shell.execute_reply.started":"2021-06-04T11:54:53.357645Z","shell.execute_reply":"2021-06-04T11:54:53.813135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}