JJUN
JJUN

Reputation: 1

How can this for loop code work? (pandas, jupyter, python)

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.

Upvotes: 0

Views: 50

Answers (1)

ArminDM
ArminDM

Reputation: 1

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

Upvotes: 0

Related Questions