分配给uint Numpy数组中缺失值的值

问题描述

由2个Python列表zx构成一个numpy数组y,其中y的值可以为0,而值{{1} }没有连续增加(即可以跳过值)。

由于x的值也可以是y,因此将0中的缺失值也分配为z会造成混淆。

避免这种混乱的最佳实践是什么?

0

解决方法

解决方案

您通常可以为# asgi.py import os from django.core.asgi import get_asgi_application from websocket_app.websocket import websocket_application os.environ.setdefault('DJANGO_SETTINGS_MODULE','websocket_app.settings') django_application = get_asgi_application() async def application(scope,receive,send): if scope['type'] == 'http': # Let Django handle HTTP requests await django_application(scope,send) elif scope['type'] == 'websocket': # handle websocket connections here await websocket_application(scope,send) else: raise NotImplementedError(f"Unknown scope type { scope['type'] }") # websocket.py async def websocket_application(scope,send): while True: event = await receive() if event['type'] == 'websocket.connect': await send({ "type": "websocket.accept" }) if event['type'] == 'websocket.disconnect': break if event['type'] == 'websocket.receive': try: # result = json.loads(event['text']) await route(scope,event,send) except Exception as e: await send({ "type": "websocket.send","text": e.__repr__() }) 中不存在的索引分配np.nan或其他任何值。

此外,不需要 for循环。您可以在一行中直接分配x的所有值,如我在此处所示。

但是,由于要强制转换为 uint32 ,因此不能使用ywhy not?)。取而代之的是,您可以使用大量的选择(例如np.nan ),这些数字在设计上不会显示在999999中。有关更多详细信息,请参阅下面的参考部分中共享的链接。

y

参考文献

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...