我是靠谱客的博主 无私月饼,这篇文章主要介绍python矩阵 条件选取行_如何根据一个条件从NumPy矩阵中得到行的子集?,现在分享给大家,希望可以做个参考。

如何返回一组符合给定条件的NumPy矩阵行?在

这是一个纽比矩阵对象>>> X

matrix([['sunny', 'hot', 'high', 'FALSE'],

['sunny', 'hot', 'high', 'TRUE'],

['overcast', 'hot', 'high', 'FALSE'],

['rainy', 'mild', 'high', 'FALSE'],

['rainy', 'cool', 'normal', 'FALSE'],

['rainy', 'cool', 'normal', 'TRUE'],

['overcast', 'cool', 'normal', 'TRUE'],

['sunny', 'mild', 'high', 'FALSE'],

['sunny', 'cool', 'normal', 'FALSE'],

['rainy', 'mild', 'normal', 'FALSE'],

['sunny', 'mild', 'normal', 'TRUE'],

['overcast', 'mild', 'high', 'TRUE'],

['overcast', 'hot', 'normal', 'FALSE'],

['rainy', 'mild', 'high', 'TRUE']],

dtype='|S8')

我想得到第一列值为'rainy'的所有行的集合,所以它尝试了这个方法

^{pr2}$

但我想要这样的输出matrix([['rainy', 'mild', 'high', 'FALSE'],

['rainy', 'cool', 'normal', 'FALSE'],

['rainy', 'cool', 'normal', 'TRUE'],

['rainy', 'mild', 'normal', 'FALSE'],

['rainy', 'mild', 'high', 'TRUE']],

dtype='|S8')

这应该怎么做?在

最后

以上就是无私月饼最近收集整理的关于python矩阵 条件选取行_如何根据一个条件从NumPy矩阵中得到行的子集?的全部内容,更多相关python矩阵内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(136)

评论列表共有 0 条评论

立即
投稿
返回
顶部