当条件针对列而不是值时按条件过滤数据框

filter dataframe by condition when the condition is for the columns and not on the values

我有一个带有浮动列的数据框,看起来与此类似:

>>>397.55    400.231   404.42  407.12  465.23  478.92  492.3  501.2  505.6  ...
0   0.23      0.122     0.43   0.11     0.345   0.22   0.66   0.34   0.21
1   0.12      0.443     0.76   0.12     0.22    0.24   0.56   0.11   0.04
2   0.45      0.87      0.23   0.99     0.11    0.44   0.78   0.65   0.23
...

我想过滤数据框,它只有值在 405.2 到 472.7 之间的列。
我试图用列上的条件过滤它,但它没有用:

df[(df.columns>405.2)]
>>>ValueError: Item wrong length 224 instead of 10783.

224 是列数,10783 是行数。

当值是列名时,有什么方法可以过滤我的数据框使其介于两个值之间?

使用DataFrame.loc,首先:表示按条件获取所有行列:

df.loc[:, (df.columns>405.2)]