LoginSignup
6
14

More than 5 years have passed since last update.

CSVへの直URLからデータを読み込む

Posted at

前略

CSVへの直URLからデータをダウンロードし、データフレーム化します。

手順

requestsでGETし、ioでテキストをストリームオブジェクトのように扱います。

import requests
import io

url = 'https://raw.githubusercontent.com/ground0state/for_qiita/master/data/iris.csv'
res = requests.get(url).content
df = pd.read_csv(io.StringIO(res.decode('utf-8')), header=0, index_col=0)
6
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
14