
Pythonはじめました。pandasで文字型式の日付の列を計算して結果の列を追加する
サンプルデータ取得
import pandas as pd
import requests
url='https://opendata.corona.go.jp/api/Covid19JapanAll' # 全国の感染者数
response = requests.get(url)
data = response.json()
d = data['itemList']
df = pd.DataFrame(d)
date 列は文字

pd.to_datetimeで文字⇒日付型に変換する。

実際の日数計算の最後は .dt.days を付けて日数にする

できました!!!

おわり
いいなと思ったら応援しよう!
