db_name_prefix with or without exp
This commit is contained in:
@@ -46,31 +46,36 @@ class ControllerDB:
|
||||
Firm.fillna(0, inplace=True)
|
||||
|
||||
# fill dct_lst_init_remove_firm_prod
|
||||
# list_dct = []
|
||||
# for _, row in Firm.iterrows():
|
||||
# code = row['Code']
|
||||
# row = row['1':]
|
||||
# for product_code in row.index[row == 1].to_list():
|
||||
# dct = {code: [product_code]}
|
||||
# list_dct.append(dct)
|
||||
str_sql = "select e_id, count, max_max_ts, " \
|
||||
"dct_lst_init_remove_firm_prod from " \
|
||||
"iiabmdb.without_exp_experiment as a " \
|
||||
"inner join " \
|
||||
"(select e_id, count(id) as count, max(max_ts) as max_max_ts " \
|
||||
"from iiabmdb.without_exp_sample as a " \
|
||||
"inner join (select s_id, max(ts) as max_ts from " \
|
||||
"iiabmdb.without_exp_result where ts > 0 group by s_id) as b " \
|
||||
"on a.id = b.s_id " \
|
||||
"group by e_id) as b " \
|
||||
"on a.id = b.e_id " \
|
||||
"order by count desc;"
|
||||
result = pd.read_sql(sql=str_sql, con=engine)
|
||||
result['dct_lst_init_remove_firm_prod'] = \
|
||||
result['dct_lst_init_remove_firm_prod'].apply(
|
||||
lambda x: pickle.loads(x))
|
||||
list_dct = result.loc[result['count'] >= 9,
|
||||
'dct_lst_init_remove_firm_prod'].to_list()
|
||||
assert self.db_name_prefix in ['test', 'without_exp', 'with_exp'], \
|
||||
"db name not in test, without_exp, with_exp"
|
||||
|
||||
list_dct = []
|
||||
if self.db_name_prefix in ['test', 'without_exp']:
|
||||
for _, row in Firm.iterrows():
|
||||
code = row['Code']
|
||||
row = row['1':]
|
||||
for product_code in row.index[row == 1].to_list():
|
||||
dct = {code: [product_code]}
|
||||
list_dct.append(dct)
|
||||
elif self.db_name_prefix in ['with_exp']:
|
||||
str_sql = "select e_id, count, max_max_ts, " \
|
||||
"dct_lst_init_remove_firm_prod from " \
|
||||
"iiabmdb.without_exp_experiment as a " \
|
||||
"inner join " \
|
||||
"(select e_id, count(id) as count, max(max_ts) as max_max_ts "\
|
||||
"from iiabmdb.without_exp_sample as a " \
|
||||
"inner join (select s_id, max(ts) as max_ts from " \
|
||||
"iiabmdb.without_exp_result where ts > 0 group by s_id) as b "\
|
||||
"on a.id = b.s_id " \
|
||||
"group by e_id) as b " \
|
||||
"on a.id = b.e_id " \
|
||||
"order by count desc;"
|
||||
result = pd.read_sql(sql=str_sql, con=engine)
|
||||
result['dct_lst_init_remove_firm_prod'] = \
|
||||
result['dct_lst_init_remove_firm_prod'].apply(
|
||||
lambda x: pickle.loads(x))
|
||||
list_dct = result.loc[result['count'] >= 9,
|
||||
'dct_lst_init_remove_firm_prod'].to_list()
|
||||
# list_dct = [{'140': ['1.4.5.1']}]
|
||||
# list_dct = [{'133': ['1.4.4.1']}]
|
||||
# list_dct = [{'2': ['1.1.3']}]
|
||||
|
||||
Reference in New Issue
Block a user