代码拉取完成,页面将自动刷新
import clickhouse_driver
import datetime
import pandas as pd
class QAFactorManager():
def __init__(self) -> None:
self.client = clickhouse_driver.Client(host='localhost',database='factor')
#self.client.execute('CREATE DATABASE factor')
def get_all_factorname(self):
data = self.client.query_dataframe('select factorname from regfactor').drop_duplicates().factorname.tolist()
return data
def get_all_tables(self):
return self.client.query_dataframe('show tables').drop_duplicates()
def get_single_factor(self, factorname):
print(factorname)
res = self.client.query_dataframe('select * from {}'.format(factorname))
if len(res)>0:
res.columns = ['date', 'code', factorname]
return res.set_index(['date', 'code']).sort_index()
else:
return pd.DataFrame([])
def unreg_factor(self, factorname):
self.client.execute("ALTER TABLE regfactor DELETE WHERE factorname='{}'".format(factorname))
self.client.execute('drop table {}'.format(factorname))
def get_all_factor_values(self, factorlist=None):
factorlist = self.get_all_factorname() if factorlist is None else factorlist
res = pd.concat([self.get_single_factor(factor) for factor in factorlist], axis=1)
return res
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。