ktl014
7/27/2017 - 6:16 PM

construct pandas dataframe with index and columns initalized (label value to name for easy interpretation)

construct pandas dataframe with index and columns initalized (label value to name for easy interpretation)

data = {'specimen': ['copepod','non-copepod'],'specimen_label':[0,1]}
df = pd.DataFrame(data,index=['img1','img2'],columns=['specimen','specimen_label'])
#         specimen  specimen_label
#img1      copepod               0
#img2  non-copepod               1
df1 = dict(zip(df.specimen.unique(),df.specimen_label.unique()))
#{'non-copepod': 1, 'copepod': 0}