Esempio n. 1
0
 def get_labels(self, labelname='Stress'):
     r = []
     series = []
     for tsd in self:
         g = tsd.df_meta.transpose().groupby(by='SeriesID')
         for k,df in g:
             series.append(k)
             r.append(df[labelname].tolist()[0])
     return pd.DataFrame(r, columns=[labelname], index=series)
Esempio n. 2
0
def modelmatrix(table, axis=0, factor_list=None):
    if (factor_list is None):
        factor_list = factor(table)
    # do factor encoding
    r = []
    if (type(table) == pd.DataFrame or type(table) == pd.Series):
        idx = table.index
        table = table.values.flatten()
    else:
        raise Exception('Only DataFrame/Series format is supported')
    for x in table.tolist():
        r.append(factor_list == x)
    return pd.DataFrame(np.array(r)*1, columns=factor_list, index=idx)
Esempio n. 3
0
 def get_labels_per_time(self, labelname='Stress'):
     r = []
     for tsd in self:
         r.append( tsd.df_meta.loc[labelname] )
     return pd.concat(r, axis=1)