Exemplo n.º 1
0
 def find(self, key_column, id, value_column):
     row = util.get_row_by_keys(self.df,
                                key_value=id,
                                key_column=key_column)
     #print('--', row)
     return row[
         value_column]  #row_ind + 2, col_ind + 1 # in wks from 0 + head
Exemplo n.º 2
0
 def transfer(self, id, new_group, key_column=None, value_column="Секция"):
     main_df = self.wks.get_as_df()
     main_row = util.get_row_by_keys(main_df,
                                     key_value=[id],
                                     key_column=key_column)
     old_wks_name = main_row[value_column].values[0]
     old_wks = util.read_sheet(
         util.affilation_wks(old_wks_name, self.graph_df)[0])
     new_wks = util.read_sheet(
         util.affilation_wks(new_group, self.graph_df)[0])
     old_row = util.get_row_by_keys(old_wks.get_as_df(),
                                    main_row[['ФИО', 'Группа']].values[0],
                                    ['ФИО', 'Группа'])
     old_wks.delete_rows(int(old_row.index[0] + 2))
     util.add_row_down(wks=new_wks, values=list(old_row.values[0]))
     col = main_df.columns.get_loc(value_column) + 1
     self.change_cell(col=col, row=main_row.index[0] + 2, val=new_group)
Exemplo n.º 3
0
 def filter_people(self, key_value=('Химфак', '2'), key_column=('Факультет','cource'), ratio="=="):
     """
     :param ratio: operation for compare any of <=. >, ==...
     :param key_value: value for compare with df value in key_col..
     :param key_column: column where we find interesting for us key
     :return: None - inplace update df
     """
     self.df = util.get_row_by_keys(self.df, key_value, key_column, ratio=ratio)
Exemplo n.º 4
0
 def add_key(self, fdf, twks, key_col):
     new_key = []
     tdf = twks.get_as_df()
     last_row = None
     blanc_row = util.get_blanc_row(tdf)
     for i, key in fdf[key_col].iterrows():
         # print(key.values)
         # print(util.get_row_by_keys(tdf, key.values, key_col).empty)
         if util.get_row_by_keys(tdf, key.values,
                                 key_col).empty:  # util.get_row_by_keys(tdf, key.values[0], key_col):
             print('ok,', key.values)
             row = util.format_row(tdf, list(key.values), key_col, blanc_row)
             new_key.append(row)
             last_row = twks.get_as_df().shape[0] + 1
     if last_row is not None:
         twks.insert_rows(row=last_row, values=new_key)
Exemplo n.º 5
0
 def get_test_res(self, ratio='25', col_name="Block1"):
     self.res_df = self.safe_transfer_to_pd_by_col(self.wks, [1,2,3])
     self.res_df["key"] = self.res_df["Email Address"].apply(self.mail_hesh)
     self.res_df["Block1"] = self.res_df["Score"].apply(self.score_to_int)
     self.res_df = util.get_row_by_keys(self.res_df, [ratio,], ['Block1'], ratio=">")
Exemplo n.º 6
0
 def open_node_by_name(self, node_name):
     row = util.get_row_by_keys(self.graph, key_column=["node_name"], key_value=[node_name])
     # print(node_name, 'r=', row)
     assert not row.empty, Exception("Can't find link_name [{}] in graph".format(node_name))
     link = row["node"].values[0]
     return util.read_sheet(util.get_sheet_id_from_link(link))