Update app.py
Browse files
app.py
CHANGED
@@ -138,6 +138,18 @@ def get_pub(x):
|
|
138 |
except:
|
139 |
return ' '
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
#def query_records(search_term):
|
142 |
|
143 |
|
@@ -269,6 +281,16 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox,sample_reduct
|
|
269 |
stacked_df = pd.concat([basedata_df,records_df], axis=0, ignore_index=True)
|
270 |
stacked_df = stacked_df.fillna("Unlabelled")
|
271 |
stacked_df = stacked_df.reset_index(drop=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
print(stacked_df)
|
273 |
|
274 |
extra_data = pd.DataFrame(stacked_df['doi'])
|
@@ -320,7 +342,9 @@ def predict(text_input, sample_size_slider, reduce_sample_checkbox,sample_reduct
|
|
320 |
|
321 |
plot = datamapplot.create_interactive_plot(
|
322 |
stacked_df[['x','y']].values,
|
323 |
-
np.array(stacked_df['cluster_1_labels']),np.array(stacked_df['cluster_2_labels']),np.array(stacked_df['cluster_3_labels']),
|
|
|
|
|
324 |
hover_text=[str(row['title']) for ix, row in stacked_df.iterrows()],
|
325 |
marker_color_array=stacked_df['color'],
|
326 |
|
|
|
138 |
except:
|
139 |
return ' '
|
140 |
|
141 |
+
def get_field(x):
|
142 |
+
|
143 |
+
try:
|
144 |
+
field = x['primary_topic']['subfield']['display_name']
|
145 |
+
if field is not None:
|
146 |
+
return field
|
147 |
+
else:
|
148 |
+
return np.nan
|
149 |
+
except:
|
150 |
+
return np.nan
|
151 |
+
|
152 |
+
|
153 |
#def query_records(search_term):
|
154 |
|
155 |
|
|
|
281 |
stacked_df = pd.concat([basedata_df,records_df], axis=0, ignore_index=True)
|
282 |
stacked_df = stacked_df.fillna("Unlabelled")
|
283 |
stacked_df = stacked_df.reset_index(drop=True)
|
284 |
+
|
285 |
+
|
286 |
+
|
287 |
+
|
288 |
+
|
289 |
+
stacked_df['parsed_field'] = [get_field(row) for ix, row in stacked_df.iterrows()]
|
290 |
+
|
291 |
+
|
292 |
+
|
293 |
+
|
294 |
print(stacked_df)
|
295 |
|
296 |
extra_data = pd.DataFrame(stacked_df['doi'])
|
|
|
342 |
|
343 |
plot = datamapplot.create_interactive_plot(
|
344 |
stacked_df[['x','y']].values,
|
345 |
+
# np.array(stacked_df['cluster_1_labels']),np.array(stacked_df['cluster_2_labels']),np.array(stacked_df['cluster_3_labels']),
|
346 |
+
np.array(['Unlabelled' if pd.isna(x) else x for x in stacked_df['parsed_field']]),
|
347 |
+
|
348 |
hover_text=[str(row['title']) for ix, row in stacked_df.iterrows()],
|
349 |
marker_color_array=stacked_df['color'],
|
350 |
|