Last active
March 10, 2020 03:03
-
-
Save ParzivalWins/a05bfec4f243a97db545ae1bd356b2c3 to your computer and use it in GitHub Desktop.
Pandas-Import-CSV-Using-Requests-Create-DataFrame
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 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