Python tushare.get_industry_classified() Examples

The following are 5 code examples of tushare.get_industry_classified(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tushare , or try the search function .
Example #1
Source File: spyder_tushare.py    From quantproject with Apache License 2.0 6 votes vote down vote up
def get_industry_classified(self):
        """
        行业分类
         code    name      c_name
        """
        
        industry = ts.get_industry_classified()
        industry = industry[['code','name','c_name']]
        industry.columns = ['code','name','industryName']
        ##合并多个行业分类
        industryDict = {}
        for line in industry.to_dict('record'):
            if industryDict.get(line['code']) is None:
                industryDict[line['code']] = []
            industryDict[line['code']].append(line['industryName'])
        industry = pd.DataFrame(industryDict.items(),columns=['code','industryName'])
        if self.data is None:
            self.data = industry 
Example #2
Source File: spyder_tushare.py    From quantproject with Apache License 2.0 5 votes vote down vote up
def __init__(self,save=True):
        """
        """
        self.columns = ['code',
                   'name',
                   'industryName',##行业名称
                   'conceptName',##概念分类
                   'areaName',##地域分类
                   'smeName',##是否属于中小板分类
                   'gemName',##是否属于创业板分类
                   'stName',##是否属于警示板分类
                   'hs300s',##是否是沪深300当前成份股及所占权重
                   'sz50s',##获取上证50成份股
                   'zz500s',##中证500成份股
                   'terminated',##终止上市股票列表
                   'suspended',##暂停上市股票列表
                   ]
        self.data = None
        self.get_industry_classified()
        self.get_concept_classified()
        self.get_area_classified()
        self.get_sme_classified()
        self.get_gem_classified()
        self.get_st_classified()
        self.get_hs300s_classified()
        self.get_sz50s_classified()
        self.get_zz500s_classified()
        self.get_terminated_classified()
        self.get_suspended_classified()
        now = dt.datetime.now()
        self.data['datatime']  =  now.strftime('%Y-%m-%d')
        self.data['datatimestramp']  =  now.strftime('%H:%M:%S')
        indexlist = ['code','datatime']##数据库索引
        tableName = 'symbClassified'  
        database(self.data,indexlist,tableName,save) 
Example #3
Source File: classify_to_sql.py    From anack with GNU General Public License v3.0 5 votes vote down vote up
def classify_info_to_sql():
    create_classify_table()    
    
    a = ts.get_industry_classified()
    a.columns = ['code', 'name', 'industry']
    b = ts.get_area_classified()
    c = ts.get_sz50s()
    c = c.iloc[:,1::]
    c['sz50'] = '1'
    d = ts.get_hs300s()
    d = d.iloc[:,1::]
    d.columns = ['code','name','hs300_weight']
    e = ts.get_zz500s()
    e = e.iloc[:,1::]
    e.columns = ['code','name','zz500_weight']
    result = pd.merge(a, b, how='left', on=None, left_on=None, right_on=None,
             left_index=False, right_index=False, sort=True,
             suffixes=('_x', '_y'), copy=True, indicator=False)
    result = pd.merge(result, c, how='left', on=None, left_on=None, right_on=None,
             left_index=False, right_index=False, sort=True,
             suffixes=('_x', '_y'), copy=True, indicator=False)
    result = pd.merge(result, d, how='left', on=None, left_on=None, right_on=None,
             left_index=False, right_index=False, sort=True,
             suffixes=('_x', '_y'), copy=True, indicator=False)
    result = pd.merge(result, e, how='left', on=None, left_on=None, right_on=None,
             left_index=False, right_index=False, sort=True,
             suffixes=('_x', '_y'), copy=True, indicator=False)
    df_to_mysql('anack_classify',result)
    
#    ------------------------------------------------------------- 
Example #4
Source File: classify.py    From anack with GNU General Public License v3.0 5 votes vote down vote up
def industry():
    return ts.get_industry_classified() 
Example #5
Source File: stock_price.py    From HeatMap_for_TuShare with MIT License 5 votes vote down vote up
def plot_days():
    if request.method == 'GET' :
        today = ts.get_today_all()
        code_info = ts.get_industry_classified()

        today['code'] = today['code'].astype(unicode)
        one_day = gd.get_data_real_time(code_info, today)
        body = heatmap.get_heatmap('Today', one_day)
        return render_template('heatmap.html', body=body)