问题
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