博客
关于我
NumPy数组的高级操作第一关
阅读量:804 次
发布时间:2019-03-25

本文共 398 字,大约阅读时间需要 1 分钟。

import numpy as np

def get_mean(feature1, feature2):"""将feature1和feature2横向拼接,然后统计拼接后的ndarray中每列的均值"""# 将两个数组按水平方向拼接combined = np.hstack((feature1, feature2))# 计算每列的平均值,并返回结果return combined.mean(axis=1)

测试用例

if name == "main":test_case = {'feature1': [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 5]],'feature2': [[1], [2], [3]]}result = get_mean(test_case['feature1'], test_case['feature2'])print(result)

转载地址:http://booyk.baihongyu.com/

你可能感兴趣的文章
Node入门之创建第一个HelloNode
查看>>
NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>
npm和yarn的使用对比
查看>>
npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
查看>>
npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
查看>>
NR,NF,FNR
查看>>
nrf开发笔记一开发软件
查看>>
NSDateFormatter的替代方法
查看>>
NSOperation基本操作
查看>>
NSSet集合 无序的 不能重复的
查看>>
NT AUTHORITY\NETWORK SERVICE 权限问题
查看>>
ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
查看>>
nullnullHuge Pages
查看>>
numpy 用法
查看>>
Numpy如何使用np.umprod重写range函数中i的python
查看>>
oauth2-shiro 添加 redis 实现版本
查看>>
OAuth2.0_JWT令牌-生成令牌和校验令牌_Spring Security OAuth2.0认证授权---springcloud工作笔记148
查看>>
OAuth2.0_JWT令牌介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记147
查看>>