예제 #1
0
def loadpanel(jsonapi, yearmin, yearmax, ctrlist):
    cleanedpanel = ''
    dataframe = load_api_data(jsonapi, '')

    allcodes = {}
    panel = []
    names = {}
    for dataitem in dataframe: 
        handle = dataitem['handle']        
	try:
	    title = dataitem['title']
	except:
	    title = handle

	names[handle] = title
        (dataset, codes) = paneldatafilter(dataitem['data'], int(yearmin), int(yearmax), ctrlist, handle)    
        if not dataset.empty:                
            panel.append(dataset)

    if panel:
        totalpanel = pd.concat(panel)
        cleanedpanel = totalpanel.dropna(axis=1, how='any')
        cleanedpanel = totalpanel
	# Replace empty values with NaN
	cleanedpanel = cleanedpanel.replace(r'', np.nan, regex=True)

    return (panel, cleanedpanel, names)
예제 #2
0
def test_stats():
    jsonapi = "http://dpe.sandbox.socialhistoryservices.org/api/datasets?handle=Panel[%27hdl%3A10622/4X6NCK%27%2C%20%27hdl%3A10622/I0YK5M%27%2C%20%27hdl%3A10622/ZWRBOY%27]"
    yearmin = '1990'
    yearmax = '2010'
    ctrlist = ''
#    ctrlist = '76,578,620,554'

    dataframe = load_api_data(jsonapi, '')

    allcodes = {}
    panel = []
    for dataitem in dataframe: 
        handle = dataitem['handle']        
        (dataset, codes) = paneldatafilter(dataitem['data'], int(yearmin), int(yearmax), ctrlist, handle)    
        if not dataset.empty:                
            panel.append(dataset)
    return panel
예제 #3
0
def test_stats():
    jsonapi = "http://dpe.sandbox.socialhistoryservices.org/api/datasets?handle=Panel[%27hdl%3A10622/4X6NCK%27%2C%20%27hdl%3A10622/I0YK5M%27%2C%20%27hdl%3A10622/ZWRBOY%27]"
    yearmin = "1990"
    yearmax = "2010"
    ctrlist = ""
    #    ctrlist = '76,578,620,554'

    dataframe = load_api_data(jsonapi, "")

    allcodes = {}
    panel = []
    for dataitem in dataframe:
        handle = dataitem["handle"]
        (dataset, codes) = paneldatafilter(dataitem["data"], int(yearmin), int(yearmax), ctrlist, handle)
        if not dataset.empty:
            panel.append(dataset)
    return panel
예제 #4
0
    def loadpanel(jsonapi, yearmin, yearmax, ctrlist):
        cleanedpanel = ''
        dataframe = load_api_data(jsonapi, '')

        allcodes = {}
        panel = []
        names = {}
        for dataitem in dataframe: 
            handle = dataitem['handle']        
    	try:
    	    title = dataitem['title']
    	except:
    	    title = handle

    	names[handle] = title
            (dataset, codes) = paneldatafilter(dataitem['data'], int(yearmin), int(yearmax), ctrlist, handle)    
            if not dataset.empty:                
                panel.append(dataset)
예제 #5
0
ctrlist = '380,250,52,850'
ctrlist = ''
result = ''
thisyear = 2010
ctrlimit = 10

modern = moderncodes(config['modernnames'], config['apiroot'])
dataframe = load_api_data(jsonapi, '')

if dataframe:
    allcodes = {}
    panel = []

    for dataitem in dataframe:
        handle = dataitem['handle']
        (dataset, codes) = paneldatafilter(dataitem['data'], int(yearmin),
                                           int(yearmax), ctrlist, handle)
        if not dataset.empty:
            panel.append(dataset)

    if panel:
        totalpanel = pd.concat(panel)
        cleanedpanel = totalpanel.dropna(axis=1, how='any')
        cleanedpanel = totalpanel

        (header, data, countries, handles, vhandles) = panel2dict(cleanedpanel)
        print data
        result = panel2csv(header, data, thisyear, countries, handles,
                           vhandles, ctrlimit, modern)
        print result
예제 #6
0
yearmax = '2015'
x = ''
ctrlist = '380,250,52,850'
ctrlist = ''
result = ''
thisyear = 2010
ctrlimit = 10

modern = moderncodes(config['modernnames'], config['apiroot'])
dataframe = load_api_data(jsonapi, '')

if dataframe:
    allcodes = {}
    panel = []

    for dataitem in dataframe: 
        handle = dataitem['handle']        
        (dataset, codes) = paneldatafilter(dataitem['data'], int(yearmin), int(yearmax), ctrlist, handle)    
        if not dataset.empty:                
            panel.append(dataset)
        
    if panel:
        totalpanel = pd.concat(panel)
        cleanedpanel = totalpanel.dropna(axis=1, how='any')
        cleanedpanel = totalpanel

        (header, data, countries, handles, vhandles) = panel2dict(cleanedpanel)           
	print data
        result = panel2csv(header, data, thisyear, countries, handles, vhandles, ctrlimit, modern)
        print result