Skip to content

Instantly share code, notes, and snippets.

@jerpint
Created April 7, 2020 19:44
Show Gist options
  • Save jerpint/f1945ac281bfc7186d777e819be13ca2 to your computer and use it in GitHub Desktop.
Save jerpint/f1945ac281bfc7186d777e819be13ca2 to your computer and use it in GitHub Desktop.
Extract questions and anwers from healthtap dataset
import ast
import pandas as pd
data = pd.read_csv('path_to_healthtap_file.csv')
all_questions = []
all_answers = []
for question, answer_format in zip(data.question, data.answers):
try:
if answer_format != "[]":
all_answers.append(ast.literal_eval(answer_format)[0]["answer"])
all_questions.append(question)
except:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment