Skip to content

Instantly share code, notes, and snippets.

@ParzivalWins
Last active March 10, 2020 03:03
Show Gist options
  • Save ParzivalWins/a05bfec4f243a97db545ae1bd356b2c3 to your computer and use it in GitHub Desktop.
Save ParzivalWins/a05bfec4f243a97db545ae1bd356b2c3 to your computer and use it in GitHub Desktop.
Pandas-Import-CSV-Using-Requests-Create-DataFrame
import requests
download_url = "https://raw.githubusercontent.com/fivethirtyeight/data/master/nba-elo/nbaallelo.csv"
target_csv_path = "nba_all_elo.csv"
response = requests.get(download_url)
response.raise_for_status() # Check that the request was successful
with open(target_csv_path, "wb") as f:
f.write(response.content)
print("Download ready.")
import pandas as pd
nba = pd.read_csv("nba_all_elo.csv")
type(nba)
#number of records
len(nba)
#dimensions
nba.shape
#last two rows
nba.tail(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment