Python で学ぶ ETL と ELT
Jake Roach
Data Engineer

生成・消費されるデータの大半は非構造化データ

API(アプリケーションプログラミングインターフェース)
$$

JSON(JavaScript Object Notation)
dict(辞書型)に似た構造{
"key": "value",
...
"open": 0.121875
}
{
"timestamps": [863703000, 863789400, ...],
"open": [0.121875, 0.098438, ...],
"close": [...],
"volume": [...]
}
.read_json() 関数を使用する
# Read in a JSON file in the format above
raw_stock_data = pd.read_json("raw_stock_data.json", orient="columns")
データが常にDataFrame形式とは限らない
{
"863703000": {
"volume": 1443120000,
"price": {
"close": 0.09791,
"open": 0.12187
}
},
"863789400": {
...
}, ...
}
import json
with open("raw_stock_data.json", "r") as file:
# Load the file into a dictionary
raw_stock_data = json.load(file)
# Confirm the type of the raw_stock_data variable
print(type(raw_stock_data))
<class 'dict'>
Python で学ぶ ETL と ELT