在Python创建的透视表中查找满足特定条件的值

2024-10-02 00:23:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Python创建了一个表:

data_pivot  = pd.pivot_table(df, values='occ', 
index='ALT_grid', columns='LCT_grid', aggfunc='count')
print(data_pivot)

该表与图中的类似: The figure shows the number of occurrences of an event of 90-130 kilometers corresponding to 1-24 hours. The minimum number of times in the table is 3 times 该图显示了与1-24小时相对应的90-130公里事件的发生次数。表中的最小次数为3次。 我想选择数字大于100的行

我的代码如下:

limit2 = data_pivot.values >=100 print(data_pivot[limit2])

然而,我得到的只是一个大于100的值,而不是一整行大于100的值。如下图所示:

enter image description here 我希望在过滤数据后,任何一行中的所有值都是>;100.

我想要的结果类似于下图,在所有行中,值都大于100

enter image description here

我查看了很多信息,但仍然无法解决此问题,非常感谢您的帮助


Tags: columnsdfdataindextablealt次数grid

热门问题