Using the read_csv() method from the Pandas library, we can read the data from an url.
Example
df = pd.read_csv(url)
Find the below working application.
read_from_url.py
import pandas as pd
url = 'https://data.cityofnewyork.us/api/views/su38-ur5m/rows.csv'
df = pd.read_csv(url)
print(df.head())
Output
DBN Bldg Code ... Grades Served Lead CBO Partner 0 01M015 M015 ... Elementary P2L PATHWAYS TO LEADERSHIP INC. 1 01M034 M034 ... K-8 University Settlement Society of New York 2 01M064 M064 ... Elementary Educational Alliance 3 01M142 M142 ... Elementary Educational Alliance 4 01M188 M188 ... K-8 Henry Street Settlement
References
https://opendata.cityofnewyork.us/data/
Previous Next Home
No comments:
Post a Comment