Hi,
I am doing loops and very confused about below shows:
opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
ratings = [ ]
for row in apps_data[1:]:
rating = float(row[7])
ratings.append(rating)
print(ratings[:5])
I am confused about the row in command of for row in apps_data[1:] and the row in rating=float(row[7]) means the same row? I mean why row[7] becomes ‘user rating’ which should be seen as column right?
The row here: for row in apps_data[1:]: relates to the whole row with all the data in it. The data in the row is separated by commas and each data point can be seen as part of a column (if you stack the rows on each other).
When you then say row[7] you select a specific entry from the row mentioned above, namely the 8th data point, which happens to be the user rating.
TLDR: row = all of the data, row[7] = one data point in the row.
Thank you so much Bojan! You explained very clear about my confused but why I can not recall this knowledge point that I have learn from previous commission, could you give me a hint so I can make a review for that.