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/']
The [`asyncio.run()`](https://docs.python.org/3.7/library/asyncio-task.html#asyncio.run) documentation says:

> 
> This function [cannot](https://github.com/python/cpython/blob/3.8/Lib/asyncio/runners.py#L32-L34) be called when another asyncio event loop is running in the same thread.
> 
> 
> 

In your case, jupyter ([IPython ≥ 7.0](https://blog.jupyter.org/ipython-7-0-async-repl-a35ce050f7f7)) is already running an event loop:

> 
> You can now use async/await at the top level in the IPython terminal and in the notebook, it should — in most of the cases — “just work”. Update IPython to version 7+, IPykernel to version 5+, and you’re off to the races.
> 
> 
> 

Therefore you don't need to start the event loop yourself and can instead call `await main(url)` directly, even if your code lies outside any asynchronous function.

**Jupyter / IPython**

```py
async def main():
    print(1)

await main()

```

**Python (≥ 3.7) or older versions of IPython**

```py
import asyncio

async def main():
    print(1)

asyncio.run(main())

```

In your code that would give:

```py
url = ['url1', 'url2']
result = await main(url)

for text in result:
    pass # text contains your html (text) response

```

**Caution**

There is a [slight difference](https://ipython.readthedocs.io/en/stable/interactive/autoawait.html#difference-between-terminal-ipython-and-ipykernel) on how Jupyter uses the loop compared to IPython.
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"

```