python - Need help understanding script syntax -


this question has answer here:

i'm new python, , while reading script, encountered following syntax:

def approximate_random_effects(data, labels, group):      correlation_per_donor = {}     donor_id in set(data[group]):         correlation_per_donor[donor_id], _, _, _, _ = \           linregress(             list(data[labels[0]][data[group] == donor_id]),             list(data[labels[1]][data[group] == donor_id]))     average_slope = np.array(correlation_per_donor.values()).mean()     t, p_val = ttest_1samp(correlation_per_donor.values(), 0) 

why lhs of correlation_per_donor[donor_id] have _, , why rhs have many () consecutive [] nested inside it? not understand , running through codeacademy's lists/dict tutorial did not help.

advice needed, thanks!

edit: comprehension of script correct? attached below:

for each donor id, 

for-loop picks out donor_id in group residing in data:

lhs has 5 variables, makes donor_id part of dictionary "correlation_per_donor"

rhs linregress on 2 lists, (labels[first item] in data, group in data == donor_id) , (labels[second item] in data, group in data == donor_id)

i don't understand why == donor_id required

_ variable name, in case used "i'm ignoring data".

the right hand side has []'s because it's nested data structure of lists , dictionaries.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -