I have a dataset in CSV file and all data is a numeric attribute, I want to apply k-Nearest Neighbors in my dataset 

I have some error in my code I don't know who I can fix it. 

code:
[enter image description here][1]
[enter image description here][2]
['https://Stackoverflow.com/questions/55409656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11273598/']
Combining the methods from Pankaj Sharma and Jean Monet, I wrote the following snippet that acts as asyncio.run (with slightly different syntax), but also works within a Jupyter notebook.

```
class RunThread(threading.Thread):
    def __init__(self, func, args, kwargs):
        self.func = func
        self.args = args
        self.kwargs = kwargs
        self.result = None
        super().__init__()

    def run(self):
        self.result = asyncio.run(self.func(*self.args, **self.kwargs))

def run_async(func, *args, **kwargs):
    try:
        loop = asyncio.get_running_loop()
    except RuntimeError:
        loop = None
    if loop and loop.is_running():
        thread = RunThread(func, args, kwargs)
        thread.start()
        thread.join()
        return thread.result
    else:
        return asyncio.run(func(*args, **kwargs))

```

Usage:

```
async def test(name):
    await asyncio.sleep(5)
    return f"hello {name}"

run_async(test, "user")  # blocks for 5 seconds and returns "hello user"

```
As cglacet mentioned that documentation says 

> 
> This function cannot be called when another asyncio event loop is
>  running in the same thread.
> 
> 
> 

You can use another thread i.e - 

```
class ResolveThread(threading.Thread):
            def __init__(self,result1,fun,url):
                self.result1= result1
                self.fun = fun
                self.url = url
                threading.Thread.__init__(self)
            def run(self):
                result1[0] = asyncio.run(self.fun(self.url))

result1 = [None]
sp = ResolveThread(result1)
sp.start()
sp.join() # connect main thread
result = result1[0]

```