0

I have a column of Transcript ID's in one .csv file that I need to match with the headers of another .csv file such as below: Headers
Column to Match I need to pick this column data that only contains the 1s in the state all column and then match those three pieces of data in the row to the three corresponding headers and their entire row of data. The data in those three rows must then be averages but if I can somehow get those three rows pruned out then that should be easy.

here is what I have so far:

    state = pd.read_csv(STATE_REPORT)
    panel_genes = pd.read_csv(PANEL_GENES)

    state_all_pruned = panel_genes[panel_genes['State All']==1].reset_index(drop=True) #find the transcripts with 1 in state all column
    #tran_matched = pd.merge(state, state_all_pruned, left_on =  right_on = ['Transcript'], how='inner')  #match them with the statereport file
    #print(state_all_pruned)
    for x in state:
        if x in state_all_pruned['Transcript'].all() and "z" :
            state[x + 'New Rows'] = state[x]
             
    state.to_csv("state_all.csv")

state all pruned gives me the following output:

0         1   HRAS     212983_at         I  ENST00000397596          1             1
1         1  CNTN1    1554784_at         D  ENST00000547849          1             0
2         1   GNG7  1566643_a_at         D  ENST00000587894          1             1

what I want fromthe state report is the matching transcripts aboves columns, such as:

ENST00000397596n
0.1153552
0.173832817
0.063817964
0.116773284
0.093153393
0.161951225
0.124709807
0.168147776
0.095481107
0.216100649

ENST00000547849n
0.008998405
0.008096939
0.006726382
0.011345014
0.006022683
0.006176055
0.009359498
0.010482783

ENST00000587894n
0.041334921
0.038718111
0.035486556
0.044752192
0.026950804
0.042437141
0.041221415

  • Please can you add data from the `state` and `panel_genes` dataframes as text in a code block, in your question. Also, can you add an expected output? https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Tom McLean Jun 21 '21 at 20:40
  • @TomMcLean I have edited the page, let me know if that helps. – Guitarman045 Jun 21 '21 at 21:02
  • Can you just do `state[panel_genes[panel_genes["State All"]==1]["Transcript"]]`? – Tom McLean Jun 21 '21 at 21:07
  • @TomMcLean No I tried this and it says "None of [Index(['ENST00000397596', 'ENST00000547849', 'ENST00000587894'], dtype='object')] are in the [columns]" These are two different csv files that I am interacting with, where I match these 3 with the columns of the other csv file. – Guitarman045 Jun 22 '21 at 00:05

0 Answers0