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

你可能感兴趣的文章
Spring Boot(七十六):集成Redisson实现布隆过滤器(Bloom Filter)
查看>>
passwd命令限制用户密码到期时间
查看>>
Spring @Async执行异步方法的简单使用
查看>>
PAT (Basic Level) Practice 乙级1031-1040
查看>>
PAT (Basic Level) Practice 乙级1041-1045
查看>>
PAT (Basic Level) Practice 乙级1051-1055
查看>>
PAT (Basic Level) Practise - 写出这个数
查看>>
PAT 1027 Colors in Mars
查看>>
PAT 1127 ZigZagging on a Tree[难]
查看>>
PAT 2-07. 素因子分解(20)
查看>>
SparkSQL学习03-数据读取与存储
查看>>
PAT L2-012. 关于堆的判断
查看>>
PAT Spell It Right [非常简单]
查看>>
PAT-1044. Shopping in Mars (25)
查看>>
PAT-乙级-1040 有几个PAT
查看>>
PAT1093 Count PAT's (25)(逻辑题)
查看>>
PATA1038题解(需复习)
查看>>
Patching Array
查看>>
PatchMatchStereo可能会需要的Rectification
查看>>
Path does not chain with any of the trust anchors
查看>>