【发布时间】:2022-10-06 15:11:21
【问题描述】:
应用重复变量创建时找不到索引。 我不确定如何用 2 个数据框过滤它。
代码
index_100 = globals()[\'df_n{}\'.format(i)][\'value\'].index(100)
错误
\'RangeIndex\' object is not callable
应用重复变量创建时找不到索引。 我不确定如何用 2 个数据框过滤它。
index_100 = globals()[\'df_n{}\'.format(i)][\'value\'].index(100)
\'RangeIndex\' object is not callable
如果要查找索引中的第 101 个元素,则需要使用 [] 进行索引
index_100 = globals()['df_n{}'.format(i)]['value'].index[100]
【讨论】:
globals()['df_n{}'.format(i)]==100 返回一个布尔数据帧,而数据帧是二维 numpy 数组。您不能将其用作索引。如果您的原始问题得到解决,您可以单击接受按钮。
index_100 = globals()['df_n{}'.format(i)]['value'].index[globals()['df_n{}'.format(i)]['value']==100] --> Int64Index([11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, ... 11475, 11476, 11477、11478、11479、11480、11481、11482、11483、11484]