API Call- Statistics Sweden

我与影子孤独终老i 提交于 2021-02-20 04:12:33

问题


I am trying to access the following API URL and convert it into a Pandas DataFrame:

http://api.scb.se/OV0104/v1/doris/sv/ssd/START/BE/BE0101/BE0101A/BefolkningR1860

My goal is to read this JSON file into a pandas data frame and display years as index and the population of Sweden as values.

These are the values for each year:

- 2012: 9 555 893 
- 2013: 9 644 864
- 2014: 9 747 355

My solution looks like this so far:

import pandas as pd

url = 'http://api.scb.se/OV0104/v1/doris/sv/ssd/START/BE/BE0101/BE0101A/BefolkningR1860'

df = pd.read_json(url)

print(df['variables'][3]['valueTexts'])

I have identified the years, but not sure how to access the values.

Thank you in advance for your support.

来源:https://stackoverflow.com/questions/35231815/api-call-statistics-sweden

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!