0

i am a student working in bioinformatics using scanpy, python. During finding marker genes, i was going to make a data frame. The following is the code.

pd.DataFrame({group + '_' + key[:1] : result[key][group] for group in groups for key in ['names', 'pvals']}).head(5)

My question here are two:

  1. the for statement does not have a ':' mark
  2. and the naming of the 'group' and 'key' is done after, how does it affect the previous one(group + '_' + key[:1] : result[key][group])?

I want to understand the code.

JJUN
  • 1

1 Answers1

0

What exists in Python is that in order to create and use the list, it is not important be named before use. Just taking a name from it while working is enough for Python

ArminDM
  • 1
  • 1
  • Then do you mean that the order in which variables are created and used does not matter? – JJUN Jan 14 '23 at 04:49
  • @JJUN you can ignore this answer, it is incorrect. Read about dictionary comprehensions – mozway Jan 14 '23 at 06:09