After I applied pubmed parser to Pubmed Open Access dataset. I want to create json file that has dictionary structure i.e. {{col_name1: "", col_name2: ""}, {col_name1: "", col_name2: ""}, ...}
So I select only subset of my dataframe, remove unused column and use orient='index'
to convert dataframe to json file
pubmed_map = pd.read_csv('pubmed_city_cartodb.csv')
n_sel = np.random.randint(0, len(pubmed_map), size=100)
pubmed_map = pubmed_map.drop('Unnamed: 0', 1)
pubmed_map_sel = pubmed_map.iloc[n_sel]
pubmed_map_sel_rid = pubmed_map_sel.reset_index().drop('index',1)
pubmed_map_sel_rid.to_json('pubmed_map_json.json', orient='index')
Alternatively,
pubmed_map_sel_rid.to_json('pubmed_map_json.json', orient='records', force_ascii=False)