现在我有大量库存数据(2GB):
StockID date Industry code 1 Industry code 2
0 10000 1986-01-06 NaN 399
1 10000 1986-01-07 NaN 399
2 10000 1986-01-08 NaN 399
3 10000 1986-01-09 NaN 399
...
我想检查两件事,
Industry code 1
或Industry code 2
['Industry code 1']=52
至53
时为['Industry code 2']!=60
或70
,反之亦然)关于第二个问题,如果您使用的是像pandas这样的库,并且数据框存储在变量df中,则可以使用以下命令检查特定情况:
df[(df['Industry code 1'] == 52 | df['Industry code 1'] == 53) & (df['Industry code 2'] < 60 | df['Industry code 2'] > 70)]
此代码特定于您提供的示例,但是您可以对其进行修改以适合您要创建的任何子集。这为您提供了一个子集,您可以随便执行任何操作(请参阅哪些股票实体遵循该模式,总共有多少个实体,等等。)>希望有帮助!