final_list = [] for _,row in dataset.iterrows(): lat = row['latitude'] lng = row['longitude'] radius = row['radius'] country_iso = row['country_iso'] tran_month = row['month'] tran_year = row['year'] start_date,end_date = get_start_end_date(tran_month,tran_year) query = get_monthly_count_query(lat,lng,radius,tran_month,tran_year,country_iso) print(query) input_json = row.to_dict() result_dataset = execute_query(query,redshift_username, redshift_password) data_json = result_dataset.to_dict(orient='records')[0] final_json = {**input_json,**data_json} final_list.append(final_json) final_dataset = pd.DataFrame(final_list) final_dataset
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter