Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created September 13, 2020 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SaraM92/808ed30694601e5eada5e283b2275ed7 to your computer and use it in GitHub Desktop.
Save SaraM92/808ed30694601e5eada5e283b2275ed7 to your computer and use it in GitHub Desktop.
#Import needed libraries
import pandas as pd
#Dataset
csv = "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv"
#Loop different chuncks and get the max of each one
result = {}
for chunk in pd.read_csv(csv, chunksize=100):
max_case = chunk["cases"].max()
max_case_county = chunk.loc[chunk['cases'] == max_case, 'county'].iloc[0]
result[max_case_county] = max_case
#Display results
print(max(result, key=result.get) , result[max(result, key=result.get)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment