[Tutor] Why Doesn't the for loop Increment?
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Jan 13 19:23:27 EST 2021
On 13/01/2021 21:00, Stephen P. Molnar wrote:
>> df = pd.read_csv('ligands_3')
>> print(df)
>>
>> for ligand in df:
>> print(ligand)
>> -=-=-=-
>>
>> Run ONLY that snippet and report with exactly what it prints.
>>
>>
> df = pd.read_csv('ligands_3')
> print(df)
>
> for ligand in df:
> print(df)
Note: Dennis asked to print ligand in the second print, not df again.
But it would hekp to label the output so we know what we areseeing:
print("DF= ", df)
and
print("Ligand = ", ligand
> 7-Phloroeckol
> 0 Aloeemodin
> 1 beta-Sitosterol
> 7-Phloroeckol
> 0 Aloeemodin
> 1 beta-Sitosterol
Because its not clear abouve what output goes with what print.
Well, actually it is here because you printed df twice....
But if you print df and ligand we need to tell them, apart.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list