text_plain_output_1.png
import bq_helper

import bq_helper
from bq_helper import BigQueryHelper
wdi = bq_helper.BigQueryHelper(active_project='patents-public-data', dataset_name='worldbank_wdi')

query1 = '\nSELECT  year, country_code,country_name, indicator_code, indicator_name, indicator_value\nFROM  `patents-public-data.worldbank_wdi.wdi_2016`\nwhere country_code  in ("GRC", "GBR", "FRA", "ITA", "BEL", "CHN","CYP","DEU","EMU","MKD","PRT","TUR","USA", "DNK")\n     and year>=2014 \n     and indicator_code not like ("per_%") \n     and indicator_code not like ("DC.DAC.%") \n     and indicator_code not like ("DT.%") \nORDER BY year DESC, indicator_code\n-- LIMIT  200;\n        '

response1 = wdi.query_to_pandas(query1)

base = 'http://test.org.newsmap/wdi-ontology/'
countryCode = base + '#countryCode'
countryName = base + '#countryName'
WDIcode = base + '#WDIcode'
WDIyear = base + '#WDIyear'
WDIname = base + '#WDIname'
WDIdescription = base + '#WDIdescription'
WDIvalue = base + '#WDIvalue'
changeLineStr = 'LLL'
doubleQuotes = '_DQ_'

response1['tuple'] = ''
response1.tuple = '<' + base + response1.country_code + '_' + response1.indicator_code + '_yearhere> ' + changeLineStr
response1.tuple = response1.tuple + '<' + countryCode + '> ' + doubleQuotes + response1.country_code + doubleQuotes + '; ' + changeLineStr
response1.tuple = response1.tuple + '<' + countryName + '> ' + doubleQuotes + response1.country_name + doubleQuotes + '; ' + changeLineStr
response1.tuple = response1.tuple + '<' + WDIcode + '> ' + doubleQuotes + response1.indicator_code + doubleQuotes + '; ' + changeLineStr
response1.tuple = response1.tuple + '<' + WDIyear + '> ' + 'yearhere; ' + changeLineStr
response1.tuple = response1.tuple + '<' + WDIname + '> ' + doubleQuotes + response1.indicator_name + doubleQuotes + '; ' + changeLineStr
response1.tuple = response1.tuple + '<' + WDIvalue + '> _DQ_valuehere_DQ_^^<http://www.w3.org/2001/XMLSchema#float>  . ' + changeLineStr
response1.shape
df = response1.copy()

df = df[['year', 'indicator_value', 'tuple']]
df.to_excel('kaggle_wdidata.xlsx', index=False)

df = df[(df['country_name'] == 'Greece') & (df['year'] == 2014) & (df['indicator_code'] == 'SL.UEM.TOTL.ZS')]
df = df[['year', 'indicator_value', 'tuple']]
df.head(10)