@pandas_udf(p3, PandasUDFType.GROUPED_MAP)
def _top10(key, df2):
    global dailymarket
    global k
    df = pd.concat([df2, pd.DataFrame(columns=add3_struct, dtype='float')])
    market = dailymarket[(dailymarket.industry == key[0])]
    ud.append(key[0])
    df.loc[:, 'key_flag'] = key[0]
    if market.shape[0]:
        df.loc[:, 'industry_roe_buy'] = (df.industry_roe - market[(market.category == 'industry_roe')].per90[0])
        df.loc[:, 'industry_pe_buy'] = (df.industry_pe - market[(market.category == 'industry_pe')].per85[0])
        df.loc[:, 'q_dtprofit_poly_buy'] = (df.q_dtprofit_poly - market[(market.category == 'q_dtprofit_poly')].per85[0])
        df.loc[:, 'industry_roe_ttm_buy'] = (df.roe_ttm - market[(market.category == 'roe_ttm')].per90[0])
        df.loc[:, 'industry_pe_ttm_buy'] = (df.industry_pe_ttm - market[(market.category == 'industry_pe_ttm')].per85[0])
        df.loc[:, 'q_dtprofit_ttm_poly_buy'] = (df.q_dtprofit_ttm_poly - market[(market.category == 'q_dtprofit_ttm_poly')].per85[0])
        df.loc[:, 'industry_roe_buy_mad'] = (df.industry_roe - market[(market.category == 'industry_roe_mad')].per90[0])
        df.loc[:, 'industry_pe_buy_mad'] = (df.industry_pe - market[(market.category == 'industry_pe_mad')].per85[0])
        df.loc[:, 'q_dtprofit_poly_buy_mad'] = (df.q_dtprofit_poly - market[(market.category == 'q_dtprofit_poly_mad')].per85[0])
        df.loc[:, 'industry_roe_ttm_buy_mad'] = (df.roe_ttm - market[(market.category == 'roe_ttm_mad')].per90[0])
        df.loc[:, 'industry_pe_ttm_buy_mad'] = (df.industry_pe_ttm - market[(market.category == 'industry_pe_ttm_mad')].per85[0])
        df.loc[:, 'q_dtprofit_ttm_poly_buy_mad'] = (df.q_dtprofit_ttm_poly - market[(market.category == 'q_dtprofit_ttm_poly_mad')].per85[0])
    else:
        k = (k + 1)
        d.append(key[0])
    return df
@pandas_udf(p3, PandasUDFType.GROUPED_MAP)
def _top10(key, df2):
    global dailymarket
    global k
    df = pd.concat([df2, pd.DataFrame(columns=add3_struct, dtype='float')])
    market = dailymarket[(dailymarket.industry == key[0])]
    ud.append(key[0])
    df.loc[:, 'key_flag'] = key[0]
    if market.shape[0]:
        df.loc[:, 'industry_roe_buy'] = (df.industry_roe - market[(market.category == 'industry_roe')].per90[0])
        df.loc[:, 'industry_pe_buy'] = (df.industry_pe - market[(market.category == 'industry_pe')].per85[0])
        df.loc[:, 'q_dtprofit_poly_buy'] = (df.q_dtprofit_poly - market[(market.category == 'q_dtprofit_poly')].per85[0])
        df.loc[:, 'industry_roe_ttm_buy'] = (df.roe_ttm - market[(market.category == 'roe_ttm')].per90[0])
        df.loc[:, 'industry_pe_ttm_buy'] = (df.industry_pe_ttm - market[(market.category == 'industry_pe_ttm')].per85[0])
        df.loc[:, 'q_dtprofit_ttm_poly_buy'] = (df.q_dtprofit_ttm_poly - market[(market.category == 'q_dtprofit_ttm_poly')].per85[0])
        df.loc[:, 'industry_roe_buy_mad'] = (df.industry_roe - market[(market.category == 'industry_roe_mad')].per90[0])
        df.loc[:, 'industry_pe_buy_mad'] = (df.industry_pe - market[(market.category == 'industry_pe_mad')].per85[0])
        df.loc[:, 'q_dtprofit_poly_buy_mad'] = (df.q_dtprofit_poly - market[(market.category == 'q_dtprofit_poly_mad')].per85[0])
        df.loc[:, 'industry_roe_ttm_buy_mad'] = (df.roe_ttm - market[(market.category == 'roe_ttm_mad')].per90[0])
        df.loc[:, 'industry_pe_ttm_buy_mad'] = (df.industry_pe_ttm - market[(market.category == 'industry_pe_ttm_mad')].per85[0])
        df.loc[:, 'q_dtprofit_ttm_poly_buy_mad'] = (df.q_dtprofit_ttm_poly - market[(market.category == 'q_dtprofit_ttm_poly_mad')].per85[0])
    else:
        k = (k + 1)
        d.append(key[0])
    return df