I am a python beginner and I have a python DataFrame with 5 columns as shown below. I need to check if value in column a is 1 then stack the corresponding value in column d and e together. Likewise I would check if value in column a is 2 then stacking the corresponding value in column d and e and so on of value in a = 3.
a b c d e
1 2 0.57735 -0.456086 9
1 3 0.57735 -0.456086 9
3 1 0.57735 -0.456086 9
1 2 0.57735 -0.456086 9
2 1 0.57735 -0.456086 9
My initial approach looks like this,
data= pd.read_csv('data.csv',usecols=['a','b','c','d','e'])
dis_j= pd.DataFrame(data)
if dis_j['at1']==1:
sub_1 = np.stack(dis_j['d'], dis_j['e'])
However, it does not work properly. Looking forward to your comments. Thanks!