且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

过滤2D numpy数组

更新时间:2022-05-07 00:46:29

您应仅在 first 列上执行条件:

You should perform the condition only over the first column:

x_displayed = xy_dat[((xy_dat[:,0] > min) & (xy_dat[:,0] < max))]

我们在这里构建的视图仅考虑使用xy_dat[:,0]的第一列.现在,检查此1d是否在边界之间,我们构造一个应保留的行的 1D 布尔数组,然后通过将其用作xy_dat[..]参数中的项来选择这些行

What we do here is constructing a view where we only take into account the first column with xy_dat[:,0]. By now checking if this 1d is between bounds, we construct a 1D boolean array of the rows we should retain, and now we make a selection of these rows by using it as item in the xy_dat[..] parameter.