2017-11-01 26 views
-2

選択し、人口の国勢調査データから辞書にデータを入れて、私が持っている後:私は(%は、常にこれらの年間で増加しているかどうかを確認、その後、順番に年間取得しようとしているdictの値を増やす方法は?

data = {'1991': {'0-to-14-percent': 20.85, 'year': '1991', '0-to-14 count': 5692555.0, '65-and-over-count': 3169970.0, '65-and-over-percent': 11.61, '15-to-64-count': 18434335.0, 'total-count': 27296860.0, '15-to-64-percent': 67.53}, '1981': {'0-to-14-percent': 22.52, 'year': '1981', '0-to-14 count': 5481100.0, '65-and-over-count': 2360975.0, '65-and-over-percent': 9.7, '15-to-64-count': 16501100.0, 'total-count': 24343175.0, '15-to-64-percent': 67.79}, '1941': {'0-to-14-percent': 27.8, 'year': '1941', '0-to-14 count': 3198551.0, '65-and-over-count': 767815.0, '65-and-over-percent': 6.67, '15-to-64-count': 7540289.0, 'total-count': 11506655.0, '15-to-64-percent': 65.53}, ('1941', {'0-to-14-percent': 27.8, 'year': '1941', '0-to-14 count': 3198551.0, '65-and-over-count': 767815.0, '65-and-over-percent': 6.67, '15-to-64-count': 7540289.0, 'total-count': 11506655.0, '15-to-64-percent': 65.53}) 

増加している場合はYesを返します)。ありがとうございました。

答えて

1

あなたの辞書は正しく構成されていませんが、以下の正しい辞書を実装して解決策を提供しました。

data = {'1991': {'0-to-14-percent': 20.85, 'year': '1991', '0-to-14 count': 5692555.0, '65-and-over-count': 3169970.0, '65-and-over-percent': 11.61, '15-to-64-count': 18434335.0, 'total-count': 27296860.0, '15-to-64-percent': 67.53}, '1981': {'0-to-14-percent': 22.52, 'year': '1981', '0-to-14 count': 5481100.0, '65-and-over-count': 2360975.0, '65-and-over-percent': 9.7, '15-to-64-count': 16501100.0, 'total-count': 24343175.0, '15-to-64-percent': 67.79}, '1941': {'0-to-14-percent': 27.8, 'year': '1941', '0-to-14 count': 3198551.0, '65-and-over-count': 767815.0, '65-and-over-percent': 6.67, '15-to-64-count': 7540289.0, 'total-count': 11506655.0, '15-to-64-percent': 65.53}, '1941':{'0-to-14-percent': 27.8, 'year': '1941', '0-to-14 count': 3198551.0, '65-and-over-count': 767815.0, '65-and-over-percent': 6.67, '15-to-64-count': 7540289.0, 'total-count': 11506655.0, '15-to-64-percent': 65.53}} 
final_data = {a:b['65-and-over-percent'] for a, b in data.items()} 

出力:

{'1991': 11.61, '1941': 6.67, '1981': 9.7} 

あなただけのリストが必要な場合:

final_data = [b['65-and-over-percent'] for a, b in data.items()] 

出力:

​​
+0

おかげで、申し訳ありません私の質問は、右それほどではなかった、私だけそれを編集しました。私は% – user8786892

+0

@ user8786892を私の間違いを探していた。私の最近の編集を見てください。 – Ajax1234

関連する問題