Python 時系列分析 1,000本ノック
– ノック54: パーセンテージ変化 –

Python 時系列分析 1,000本ノック– ノック54: パーセンテージ変化 –
次の Python コードの出力はどれでしょうか?

Python コード:

import pandas as pd

# 年別人口データ
data = [1000, 1050, 1100, 1150, 1200, 1250]
years = pd.date_range(
    start='2015-01-01', periods=6, freq='A')
population = pd.Series(
    data, index=years)

# 人口データの年次パーセンテージ変化を計算
change = population.pct_change().round(2)*100
print(change.values)

 

回答の選択肢:

(A) 1. 5. 5. 5. 5. 5.
(B) nan 5. 5. 5. 4. 4.
(C) nan 5. 10. 15. 20. 25.
(D) 1. 5. 10. 15. 20. 25.