标题非常混乱,所以让我解释一下。我有一个熊猫专栏:
x | desired x
1.5 | 1
1 | 1
1 | 1
1 | 1
1 | 1
0 | 0
0 | 0
0 | 0
0 | 0
1 | 0
0 | 0
-1.5|-1
-1 |-1
-1 |-1
-1 |-1
0 | 0
0 | 0
0 | 0
0 | 0
-1 | 0
0 | 0
0 | 0
1.5 | 1
...
当前,我已经使用itertuples解决了这个问题:
currval = np.nan
for idx in df.itertuples():
if idx[33] == 1.5:
currval = 1
elif idx[33] == -1.5:
currval = -1
elif idx[32] <> "":
currval = np.nan
else:
next
df.loc[idx.Index,'refPos2'] = currval
但是,这段代码太慢了,想知道是否有人对如何向量化提出了想法。
谢谢!
答案 0 :(得分:0)
我从评论中了解到的问题陈述,这是解决方案:
View myView = findViewById(R.id.my_view);
myView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// ... Respond to touch events
return true;
}});