Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Pandas: Grabbing values from three different columns based on values in first column

I have a dataframe that looks like this:

rowid,kepid,kepoi_name,kepler_name,koi_disposition,koi_vet_stat,koi_vet_date,koi_pdisposition,koi_score,koi_fpflag_nt,koi_fpflag_ss,koi_fpflag_co,koi_fpflag_ec,koi_disp_prov,koi_comment,koi_period,koi_time0bk,koi_time0,koi_eccen,koi_longp,koi_impact,koi_duration,koi_ingress,koi_depth,koi_ror,koi_srho,koi_fittype,koi_prad,koi_sma,koi_incl,koi_teq,koi_insol,koi_dor,koi_limbdark_mod,koi_ldm_coeff4,koi_ldm_coeff3,koi_ldm_coeff2,koi_ldm_coeff1,koi_parm_prov,koi_max_sngle_ev,koi_max_mult_ev,koi_model_snr,koi_count,koi_num_transits,koi_tce_plnt_num,koi_tce_delivname,koi_quarters,koi_bin_oedp_sig,koi_trans_mod,koi_model_dof,koi_model_chisq,koi_datalink_dvr,koi_datalink_dvs,koi_steff,koi_slogg,koi_smet,koi_srad,koi_smass,koi_sage,koi_sparprov,ra,dec,koi_kepmag,koi_gmag,koi_rmag,koi_imag,koi_zmag,koi_jmag,koi_hmag,koi_kmag,koi_fwm_stat_sig,koi_fwm_sra,koi_fwm_sdec,koi_fwm_srao,koi_fwm_sdeco,koi_fwm_prao,koi_fwm_pdeco,koi_dicco_mra,koi_dicco_mdec,koi_dicco_msky,koi_dikco_mra,koi_dikco_mdec,koi_dikco_msky
1,10797460,K00752.01,Kepler-227 b,CONFIRMED,Done,2018-08-16,CANDIDATE,1.0000,0,0,0,0,q1_q17_dr25_sup_koi,NO_COMMENT,9.488035570,170.5387500,2455003.539,0,,0.1460,2.95750,,6.158E+02,0.022344,3.20796,LS+MCMC,2.26,0.0853,89.66,793.0,93.59,24.810000,Claret (2011 A&A 529 75) ATLAS LS,0.0000,0.0000,0.2291,0.4603,q1_q17_dr25_koi,5.1358490,28.4708200,35.80,2,142,1,q1_q17_dr25_tce,11111111111111111000000000000000,0.68640,Mandel and Agol (2002 ApJ 580 171),,,010/010797/010797460/dv/kplr010797460-20160209194854_dvr.pdf,010/010797/010797460/dv/kplr010797460-001-20160209194854_dvs.pdf,5455.00,4.467,0.1400,0.9270,0.9190,,q1_q17_dr25_stellar,291.934230,48.141651,15.347,15.890,15.270,15.114,15.006,14.082,13.751,13.648,0.002,19.462294000,48.14191000,0.43000,0.94000,-2E-04,-5.5E-04,-0.0100,0.2000,0.2000,0.0800,0.3100,0.3200
2,10797460,K00752.02,Kepler-227 c,CONFIRMED,Done,2018-08-16,CANDIDATE,0.9690,0,0,0,0,q1_q17_dr25_sup_koi,NO_COMMENT,54.418382700,162.5138400,2454995.514,0,,0.5860,4.50700,,8.748E+02,0.027954,3.02368,LS+MCMC,2.83,0.2734,89.57,443.0,9.11,77.900000,Claret (2011 A&A 529 75) ATLAS LS,0.0000,0.0000,0.2291,0.4603,q1_q17_dr25_koi,7.0276690,20.1095070,25.80,2,25,2,q1_q17_dr25_tce,11111111111111111000000000000000,0.00230,Mandel and Agol (2002 ApJ 580 171),,,010/010797/010797460/dv/kplr010797460-20160209194854_dvr.pdf,010/010797/010797460/dv/kplr010797460-002-20160209194854_dvs.pdf,5455.00,4.467,0.1400,0.9270,0.9190,,q1_q17_dr25_stellar,291.934230,48.141651,15.347,15.890,15.270,15.114,15.006,14.082,13.751,13.648,0.003,19.462265000,48.14199000,-0.63000,1.23000,6.6E-04,-1.05E-03,0.3900,0.0000,0.3900,0.4900,0.1200,0.5000
3,10811496,K00753.01,,CANDIDATE,Done,2018-08-16,CANDIDATE,0.0000,0,0,0,0,q1_q17_dr25_sup_koi,DEEP_V_SHAPED,19.899139950,175.8502520,2455008.850,0,,0.9690,1.78220,,1.0829E+04,0.154046,7.29555,LS+MCMC,14.60,0.1419,88.96,638.0,39.30,53.500000,Claret (2011 A&A 529 75) ATLAS LS,0.0000,0.0000,0.2711,0.3858,q1_q17_dr25_koi,37.1597670,187.4491000,76.30,1,56,1,q1_q17_dr25_tce,11111101110111011000000000000000,0.66240,Mandel and Agol (2002 ApJ 580 171),,,010/010811/010811496/dv/kplr010811496-20160209194854_dvr.pdf,010/010811/010811496/dv/kplr010811496-001-20160209194854_dvs.pdf,5853.00,4.544,-0.1800,0.8680,0.9610,,q1_q17_dr25_stellar,297.004820,48.134129,15.436,15.943,15.390,15.220,15.166,14.254,13.900,13.826,0.278,19.800320700,48.13412000,-0.02100,-0.03800,7E-04,6E-04,-0.0250,-0.0340,0.0420,0.0020,-0.0270,0.0270
4,10848459,K00754.01,,FALSE POSITIVE,Done,2018-08-16,FALSE POSITIVE,0.0000,0,1,0,0,q1_q17_dr25_sup_koi,MOD_ODDEVEN_DV---MOD_ODDEVEN_ALT---DEEP_V_SHAPED,1.736952453,170.3075650,2455003.308,0,,1.2760,2.40641,,8.0792E+03,0.387394,0.22080,LS+MCMC,33.46,0.0267,67.09,1395.0,891.96,3.278000,Claret (2011 A&A 529 75) ATLAS LS,0.0000,0.0000,0.2865,0.3556,q1_q17_dr25_koi,39.0665500,541.8951000,505.60,1,621,1,q1_q17_dr25_tce,11111110111011101000000000000000,0.00000,Mandel and Agol (2002 ApJ 580 171),,,010/010848/010848459/dv/kplr010848459-20160209194854_dvr.pdf,010/010848/010848459/dv/kplr010848459-001-20160209194854_dvs.pdf,5805.00,4.564,-0.5200,0.7910,0.8360,,q1_q17_dr25_stellar,285.534610,48.285210,15.597,16.100,15.554,15.382,15.266,14.326,13.911,13.809,0.000,19.035637620,48.28521050,-0.11100,0.00200,3.02E-03,-1.42E-03,-0.2490,0.1470,0.2890,-0.2570,0.0990,0.2760
5,10854555,K00755.01,Kepler-664 b,CONFIRMED,Done,2018-08-16,CANDIDATE,1.0000,0,0,0,0,q1_q17_dr25_sup_koi,NO_COMMENT,2.525591777,171.5955500,2455004.596,0,,0.7010,1.65450,,6.033E+02,0.024064,1.98635,LS+MCMC,2.75,0.0374,85.41,1406.0,926.16,8.750000,Claret (2011 A&A 529 75) ATLAS LS,0.0000,0.0000,0.2844,0.3661,q1_q17_dr25_koi,4.7499450,33.1919000,40.90,1,515,1,q1_q17_dr25_tce,01111111111111111000000000000000,0.30900,Mandel and Agol (2002 ApJ 580 171),,,010/010854/010854555/dv/kplr010854555-20160209194854_dvr.pdf,010/010854/010854555/dv/kplr010854555-001-20160209194854_dvs.pdf,6031.00,4.438,0.0700,1.0460,1.0950,,q1_q17_dr25_stellar,288.754880,48.226200,15.509,16.015,15.468,15.292,15.241,14.366,14.064,13.952,0.733,19.250325800,48.22626000,-0.01000,0.23000,8E-05,-7E-05,0.0300,-0.0900,0.1000,0.0700,0.0200,0.0700

For a particular kepid I would like to grab the koi_impact, koi_duration and koi_depth from the same row. These three values will eventually be used in a training set for a neural network. Is there a convenient way to do this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

value = 10797460
df.loc[df['kepid']==value, ['koi_impact', 'koi_duration', 'koi_depth']]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading