df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}, index=['a', 'b', 'c'])
# Out[75]:
# A B
# a 1 4
# b 2 5
# c 3 6
for col in df:
print(col)
# A
# B
for key, column in df.iteritems():
print(key)
print(column)
# A
# a 1
# b 2
# c 3
# Name: A, dtype: int64
# B
# a 4
# b 5
# c 6
# Name: B, dtype: int64
for key, row in df.iterrows():
print(key)
print(row)
# a
# A 1
# B 4
# Name: a, dtype: int64
# b
# A 2
# B 5
# Name: b, dtype: int64
# c
# A 3
# B 6
# Name: c, dtype: int64