博客
关于我
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/

你可能感兴趣的文章
Python setuptools sdist:仅安装版本化文件
查看>>
Python Shell下使用matplotlib
查看>>
Python Slice How-to,我知道Python Slice,但我怎么才能使用内置的Slice对象呢?
查看>>
python socket分包发送数据
查看>>
python socket模块_Python socket模块实现TCP服务端客户端
查看>>
Python SOCKS5代理客户端HTTPS
查看>>
Python Soc网络分析:通过使用函数迭代列表来计算机会网络
查看>>
python转换已转义的字符串
查看>>
Python Sphinx自动摘要:成员函数的自动列表
查看>>
Python SQL和NoSQL数据库操作实战
查看>>
python stdout flush_sys.stdout.flush()方法的用法
查看>>
python string 运算
查看>>
Python str与bytes之间的转换
查看>>
Python subprocess ffmpeg
查看>>
python subprocess Permission denied Errno 13
查看>>
Python subprocess.call - 将变量添加到 subprocess.call
查看>>
Python Subprocess.Popen 从一个线程
查看>>
Python subprocess.Popen 作为 Windows 上的不同用户
查看>>
Python转换PPT为PDF
查看>>
Python subprocess.Popen() 等待完成
查看>>