# Data iteration code inquiry - Traffic dataset

My Code:

``````import pandas as pd
import matplotlib.pyplot as plt

traffic['Slowness in traffic (%)'] = traffic['Slowness in traffic (%)'].str.replace(',', '.')
traffic['Slowness in traffic (%)'] = traffic['Slowness in traffic (%)'].astype(float)

days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
traffic_per_day = {}
for i, day in zip(range(0, 135, 27), days):
each_day_traffic = traffic[i:i+27]
traffic_per_day[day] = each_day_traffic

for day in days:
traffic_per_day[day].plot.line(x='Hour (Coded)', y='Slowness in traffic (%)')
plt.title(day)
plt.ylim([0,25])
plt.show()
``````

in this sentence - for i, day in zip(range(0, 135, 27), days): what does it mean for zip(range(0, 135, 27), days)?

Rather than me just explaining it, try this bit of code and see if you can tell what it’s doing:

``````for i, day in zip(range(0, 135, 27), days):
print('i = ', i, 'day = ', day, '\n\n')
``````

Let me know if it still doesn’t make sense and we can try something else to help clarify it for you.

I find about the definition of zip after I asked question here. And after your example, i believe i understand better. zip package 2 files(or list?) together. If we print the result, zip match the result from two files like [1st,1st], [2nd,2nd]… and the range means the start and end number, the third number means the range between each number.

Good job! Reading the documentation is always a good place to start when you don’t understand what a function does.