text: user3345: This question comes up in my bioinfo class.
  I have a csv file containing gene names and the cluster they belong to. I want to run GESA on each individual cluster. So I would like to extract the list of gene names corresponding to each cluster. So I wrote code like this
  import pandas as pd
  gene_list = pd.read_csv('marker_genes.csv')
  for i in range(12):
      "cluster_"+str(i) = gene_list.gene[gene_list.cluster==i]
  
  I know this raises syntax error, so what is the correct way of doing it. 
  In the end, I would want cluster_0 to cluster_12 each being a list of gene names.
  
  user8573: cluster_0 to cluster_12 are just strings. they cannot be the names of arrays or matrices. Strings can only be used in print statements and string processing statements.
  The correct way to define an array or matrix is as follows: call the arrays as: cluster[0] to cluster[12]
  then, assign:  
    for i in range(12):
          cluster[i] = gene_list.gene[gene_list.cluster==i]
  
  then whenever you need to print the names of these arrays, you use:  "cluster_"+str(i)
  
original_text: 3345: <p>This question comes up in my bioinfo class.</p>
  
  <p>I have a csv file containing gene names and the cluster they belong to. I want to run GESA on each individual cluster. So I would like to extract the list of gene names corresponding to each cluster. So I wrote code like this</p>
  
  <pre><code>import pandas as pd
  gene_list = pd.read_csv('marker_genes.csv')
  for i in range(12):
      "cluster_"+str(i) = gene_list.gene[gene_list.cluster==i]
  </code></pre>
  
  <p>I know this raises syntax error, so what is the correct way of doing it. 
  In the end, I would want <code>cluster_0</code> to <code>cluster_12</code> each being a list of gene names.</p>
   8573: <p>cluster_0 to cluster_12 are just strings. they cannot be the names of arrays or matrices. Strings can only be used in print statements and string processing statements.</p>
  
  <p>The correct way to define an array or matrix is as follows: call the arrays as: cluster[0] to cluster[12]</p>
  
  <p>then, assign:  </p>
  
  <pre><code>  for i in range(12):
          cluster[i] = gene_list.gene[gene_list.cluster==i]
  </code></pre>
  
  <p>then whenever you need to print the names of these arrays, you use:  "cluster_"+str(i)</p>
  