The poor rabbit chased by Python and Anaconda :p

0%

python3 iteration summary

python 3 iteration summary

一个小小的总结,summarize一下python3里面的iteration

.iteritems()

用于 series, dataframe:

1
for index, data in a.iteritems():

iterate a list

用于不需要index的情况,只对items进行遍历

1
for data in a:

enumerate()

用于list,set等没有index的datatype

1
for index, data in enumerate(a):

.items()

用于dict,等同于.iteritems()

1
for index, data in dict.items():

.iterrows()

用于dataframe,针对每一行数据整体的iter

1
for indexname, (all data in this index) in df.iterrows():