so if I have a pandas Dataframe like:
   A  B  C  D
0  1  2  3  a 
1  2  4  6  a
2  4  8  8  b
3  2  3  5  c
and want to insert row 'E' by choosing from columns 'A', 'B', or 'C' based on conditions in column 'D', how would I go about doing this? For example: if D == a, choose 'A', else choose 'B', outputting:
   A  B  C  D  E
0  1  2  3  a  1
1  2  4  6  a  2
2  4  8  8  b  8
3  2  3  5  c  3
Thanks in advance!
This is lookup 
df.lookup(df.index,df.D.str.upper())
Out[749]: array([1, 2, 8, 5], dtype=int64)
df['E']=df.lookup(df.index,df.D.str.upper())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With