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/']
To add to `cglacet`'s answer - if one wants to detect whether a loop is running and adjust automatically (ie run `main()` on the existing loop, otherwise `asyncio.run()`), here is a snippet that may prove useful:

```py
# async def main():
#     ...

try:
    loop = asyncio.get_running_loop()
except RuntimeError:  # 'RuntimeError: There is no current event loop...'
    loop = None

if loop and loop.is_running():
    print('Async event loop already running. Adding coroutine to the event loop.')
    tsk = loop.create_task(main())
    # ^-- https://docs.python.org/3/library/asyncio-task.html#task-object
    # Optionally, a callback function can be executed when the coroutine completes
    tsk.add_done_callback(
        lambda t: print(f'Task done with result={t.result()}  << return val of main()'))
else:
    print('Starting new event loop')
    result = asyncio.run(main())

```
I found the [`unsync`](https://github.com/alex-sherman/unsync) package useful for writing code that behaves the same way in a Python script and the Jupyter REPL.

```py
import asyncio
from unsync import unsync

@unsync
async def demo_async_fn():
    await asyncio.sleep(0.1)
    return "done!"

print(demo_async_fn().result())

```