Hello,
I’ve been away from the course for a bit so a little rusty again, but I don’t understand the for loops used in “Pandas Visualizations and Grid Charts”
for i, day in zip(range(0, 135, 27), days):
I can lookup range(), but i’m only used to to for loops that take a dataset and then iterate over the rows:
“for day in days:”
Could someone explain in laymen terms what’s going on here:
“for i, day in…”
Hi ajtam555
Please provide the screen link, it will help us to help you.
I think this article will be helpful.
@ajtam555
Let’s assume that we have two variables a
and b
.
a = range (0, 3, 1)
b = ['Mon', 'Tue', 'Wed']
The zip
function will allow you iterate over these two variables at the same time.
for one, two in zip(a, b):
You get the following output:
(0, Mon)
(1, Tue)
(2, Wed)
If there’s a third variable, you can also iterate over all three with the zip
function like this:
for one, two, three in zip(a, b, c):
1 Like