Created
July 18, 2021 09:43
-
-
Save blackrez/54f36d240ebfdfb5b0ba9b7bdb7ae8cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import urllib.request | |
import codecs | |
url = "https://s3.amazonaws.com/carto-1000x/data/yellow_tripdata_2016-01.csv" | |
stream = urllib.request.urlopen(url) | |
csvfile = csv.DictReader(codecs.iterdecode(stream, 'utf-8')) | |
count = 0 | |
z = 0.0 | |
for line in csvfile: | |
z = float(line['tip_amount']) + z | |
count = count + 1 | |
print("final") | |
print(z) | |
print(count) | |
avg = z/count | |
print(avg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment