python - How to create a single element array and group them into a single array in python
问题描述
If I run the code below:
import numpy as np
np.random.binomial(n=1, p=0.2, size=[10])
I get (you may get something different because of randomness)
array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0])
How do I get the results to be in this format?
array([ [0], [1], [0], [0], [0], [0], [0], [0], [0], [0] ])
I've tried np.array. Any suggestion? I'm making a label for neural network problem.
解决方案
推荐阅读
- jpa - locust 测试 20+ 用户时无法获取 JDBC 连接
- visual-studio-code - 在 VSCode 中禁用多个游标
- python - Flask Post Data 额外大括号
- javascript - 创建在特定浏览器中打开的动态超链接
- laravel - 不知道如何在 Laravel 中设置这些数据库表
- python - Tkinter messagedialog askyesno 带有复选框?
- java - Hibernate 只在不应该返回的时候返回一条记录
- bigcommerce - 在 BigCommerce 中访问店面的元字段
- java - spring boot 无法调用存储库,因为存储库为空
- python - 组合两个数据框,将值加到相应的名称中