Exemplo n.º 1
0
 def add_date(self, dates = util.get_dates(3,3,7)):
     col_name=['key', 'suname', 'test_rool', 'group']
     df2 = pd.DataFrame(
         [[''] * len(dates)], 
         index=self.df.index, 
         columns=dates
     )
     self.df = pd.concat([self.df[col_name], df2], axis=1)
Exemplo n.º 2
0
    def generate(self,
                 category=[],
                 keys=[],
                 current_folder=None,
                 graph_wks=None):
        """
                Take main df and create own wks to each category(or group) in same drive folder
                put it to graph with backlink to main (# TODO add separete link??)
                :param main_wks:
                :param category:
                :param key:
                :return:
        """
        all_requsts_args = []
        for name in category:
            all_requsts_args.append(self.df[name].unique())
        requst = util.create_requst(category)
        generated_ids = {}

        for requst_arg in itertools.product(*all_requsts_args):
            filter_df = self.df.query(requst.format(*requst_arg))
            if not filter_df.empty:
                #print('Main , Open list', str(requst_arg), category, keys, "Extra point")
                #print(str(requst_arg), 'Main , Open list', 'Exams')
                #print(str(requst_arg))

                ##graph_wks.insert_rows(1, number=1, values=[1,2,3], inherit=False)
                #title = '_'.join([str(arg) for arg in requst_arg])
                title = requst_arg[0]
                fc = PandasForm.SheetCreator(title=title,
                                             folder_id=current_folder)
                fc.create_from_standart(dates=util.get_dates(2, 3, 7))
                #print(filter_df[keys], filter_df[keys].values)
                fc.add_objects(key_col=keys, key_val=filter_df[keys].values)
                # print(fc.df)
                wks = fc.create_sheet(self.pg)
                util.edit_col_lenth(wks)
                generated_ids[wks.spreadsheet.title] = wks.spreadsheet.id

        self.create_graph_line(
            node_short_name=self.wks.spreadsheet.title,
            node_dict={self.wks.spreadsheet.title: self.wks.spreadsheet.id},
            links_dict=generated_ids,
            args=
            '{"to_key_colname": ["ФИО", "Группа"], "to_values_colname": ["внешнии_баллы"]}'
        )
        self.create_graph_line(
            node_short_name=self.wks.spreadsheet.title,
            node_dict=generated_ids,
            links_dict={self.wks.spreadsheet.title: self.wks.spreadsheet.id},
            args=
            '{"to_key_colname": ["ФИО", "Группа"], "to_values_colname": ["посещения"]}'
        )
        return generated_ids
Exemplo n.º 3
0
    def add_column_to_df(self, new_col=util.get_dates(5, 3, 7), cur_col=None):
        """

        :param new_col: add names for new col to df
        :param cur_col: leave omly this columns, when concate with new.
        :return: None - inplace update df
        """
        print('start dates', new_col)
        df2 = pd.DataFrame([[''] * len(new_col)],
                           index=self.df.index,
                           columns=new_col)
        if cur_col is None:
            self.df = pd.concat([self.df, df2], axis=1)
        else:
            self.df = pd.concat([self.df[cur_col], df2], axis=1)
Exemplo n.º 4
0
def daily_vaccination_table():
    # daily_vaccinations = get_daily_vaccinations()
    f = open('daily_covid_statistics.json')
    world_daily_and_weekly_covid_cases = json.load(f)
    dates = get_dates()
    data = {"daily_vaccinations": []}

    for date in dates:
        data["daily_vaccinations"].append({
            "day":
            date,
            "vaccination_count":
            5000,  ## todo : just add vaccination count from db
            "covid_statistics":
            world_daily_and_weekly_covid_cases[date]
        })

    return get_response(data, 200)
Exemplo n.º 5
0
 def create_from_standart(self, dates=util.get_dates(0, 3, 7)):
     stl = StandartFormLibrary(dates)
     self.header = stl.header1
     self.formulas = stl.formulas
Exemplo n.º 6
0
        "*****@*****.**",
      ]      
    }
    request = {"addProtectedRange": {
                "protectedRange": {
                "protectedRangeId": 1,
                "range": gridrange,
                "editors": editors
            },

        }}
    pg.sh_batch_update(key, request, None, False)


if __name__ == "__main__":

    d = util.get_dates(2,3,7)
    stl = StandartFormLibrary(d)
    #for i, val in enumerate(stl.formulas):
    #   if '=' in val and val[0] == '=':
    #        number_bracets = len(re.findall('\{\}', val))
    #        stl.formulas[i] = val.format(*([2] * number_bracets))
    #        #print(val.format(2))
    #print(stl.formulas)

    ##################
    gf = SheetCreator('t1', header=stl.header1, formulas=stl.formulas, folder_id='1ncBfOFctKPVRKBYwrc58U5_UaD-d0D30')

    gf.add_objects(key_col=['ФИО', 'Группа'], key_val=[['art', 109], ['ben', 103]])
    pg = pygsheets.authorize(outh_file='other.json')
    gf.create_sheet(pg)
def CHECK_2_dates():
    dates = np.array(util.get_dates())
    landsat = dates.T[0]
    modis = dates.T[1]
    print("CHECK 2: dates")
    print(landsat == modis)
Exemplo n.º 8
0
                            #print(line['Faculty'], t_key, fv)
                #print('k', df[['suname', self.todaydate]][:8])
                #add remove teams ? ? 
                self.dest_wks.sheet1.update_col(index=self.today_col_ind + 1,
                                                row_offset=1,
                                                values=df[self.todaydate].values.tolist())
                
    def add_to_colA_if_colB(self, df, colA, colB, cond='a', val=0.3):
        df.loc[df[df[colB] == cond].index, colA] += val
    
    

if __name__ == '__main__':
    #util.read_sheet(name='ch2')
    # Open basketball form and get omly 'cl' columns. change names and df ready to sync.
    cl = [1, 2, 3, 4, 5, 6, 7, 8]
    MIN_TEST_VAL = 10
    br = Basketball_rules('1cWN-sMoaV_5NjWTcjryRx-6uxi29K9KaWt5vHa9vQog')
    br.prepare_df()

    # Get people with propertys and sync with existans
    br.filter_people(('Химфак', '2'))#('Физифак', '2'))#
    br.filter_people(key_value=[MIN_TEST_VAL,], key_column=['test_rool'], ratio=">")
    if 0: #if create new df with dates
        br.add_column_to_df(cur_col=br.cur_col, new_col=util.get_dates(9, 3, 7)) #how much days ago was saturday?
        br.add_
    br.update_or_create_from_Rool_Test('ch2') #ph2



Exemplo n.º 9
0
    stock_list = list(stock_dict.keys())
    print("TRAINING DATASET")

    print("Choose stock")

    for i, sname in enumerate(stock_list):
        print("{}. {}".format(i, sname))

    tr_symbol_ind = int(
        input("Choose a symbol (0-{}): ".format(len(stock_list) - 1)))
    tr_symbol = stock_list[tr_symbol_ind]

    print()

    #In-sample period
    sdate, edate = util.get_dates(stock_dict[tr_symbol])
    print("Choose dates from {:%Y/%m/%d} to {:%Y/%m/%d}".format(sdate, edate))

    tmp = [
        int(x)
        for x in input("Choose start date (year/month/day): ").split('/')
    ]
    while tmp[0] < sdate.year or tmp[0] > edate.year or tmp[1] < 1 or tmp[
            1] > 12 or tmp[2] < 1 or tmp[2] > 31:
        print("Choose a valid date from {:%Y/%m/%d} to {:%Y/%m/%d}".format(
            sdate, edate))
        tmp = [
            int(x)
            for x in input("Choose start date (year/month/day): ").split('/')
        ]
    tr_sdate = dt.datetime(tmp[0], tmp[1], tmp[2])
Exemplo n.º 10
0
    def prepare_df(self):
        self.df = self.safe_load(self.col_list)
        self.df.rename(columns=self.col_to_rename, inplace=True)
        self.df['key'] = self.df['key'].apply(self.mail_hesh)
        self.df['key'] = self.df['key'].apply(
            str)  # int to long for google docs
        self.df['cource'] = self.df['group'].apply(self.get_cource)
        self.df['test_rool'] = self.df['test_rool'].apply(self.score_to_int)

    def get_df(self):
        return self.df


if __name__ == '__main__':
    # Open basketball form and get omly 'cl' columns. change names and df ready to sync.
    cl = [1, 2, 3, 4, 5, 6, 7, 8]
    br = Basketball_rules('1cWN-sMoaV_5NjWTcjryRx-6uxi29K9KaWt5vHa9vQog')
    br.prepare_df()

    # Get people with propertys and sync with existans
    br.filter_people(('Химфак', '2'))  #('Физифак', '2'))
    br.filter_people(key_value=[
        '10',
    ], key_column=['test_rool'], ratio=">")
    if 0:  #if create new df
        br.add_column_to_df(cur_col=br.cur_col,
                            new_col=util.get_dates(
                                5, 3, 7))  #how much days ago was saturday?
    #print(list(br.df))
    br.update_or_create_from_Rool_Test('ch2')  #ph2