I\'m using AWS Athena to query raw data from S3. Since Athena writes the query output into S3 output bucket I used to do:
df = pd.read_csv(OutputLocation)
Try this approach to convert response['records'] into dataframe using columnMetadata:
def results_to_df(response):
columns = [
col['label']
for col in response['columnMetadata']
]
listed_results = [[list(col.values())[0] if list(col.values())[0] else '' for col in
record] for record in response['records']]
df = pd.DataFrame(listed_results, columns=columns)
return df