def get_ppi():
 rdint = vs.random()
 request = Request((vs.MACRO_URL % (vs.P_TYPE['http'], vs.DOMAINS['sina'], rdint, vs.MACRO_TYPE[1], 3, 600, rdint)))
 text = urlopen(request, timeout=10).read()
 text = (text.decode('gbk') if ct.PY3 else text)
 regSym = re.compile('\\,count:(.*?)\\}')
 datastr = regSym.findall(text)
 datastr = datastr[0]
 datastr = datastr.split('data:')[1]
 js = json.loads(datastr)
 df = pd.DataFrame(js, columns=vs.PPI_COLS)
 for i in df.columns:
  df[i] = df[i].apply((lambda x: np.where((x is None), np.NaN, x)))
  if (i != 'month'):
   df[i] = df[i].astype(float)
 return df

def get_ppi ( ) : rdint = vs . random ( ) request = Request ( ( vs . MACRO_URL % ( vs . P_TYPE [ 'http' ] , vs . DOMAINS [ 'sina' ] , rdint , vs . MACRO_TYPE [ 1 ] , 3 , 600 , rdint ) ) ) text = urlopen ( request , timeout = 10 ) . read ( ) text = ( text . decode ( 'gbk' ) if ct . PY3 else text ) regSym = re . compile ( '\\,count:(.*?)\\}' ) datastr = regSym . findall ( text ) datastr = datastr [ 0 ] datastr = datastr . split ( 'data:' ) [ 1 ] js = json . loads ( datastr ) df = pd . DataFrame ( js , columns = vs . PPI_COLS ) for i in df . columns : df [ i ] = df [ i ] . apply ( ( lambda x : np . where ( ( x is None ) , np . NaN , x ) ) ) if ( i != 'month' ) : df [ i ] = df [ i ] . astype ( float ) return df
return dataframe month :统计月份 ppiip :工业品出厂价格指数 ppi :生产资料价格指数 qm:采掘工业价格指数 rmi:原材料工业价格指数 pi:加工工业价格指数 cg:生活资料价格指数 food:食品类价格指数 clothing:衣着类价格指数 roeu:一般日用品价格指数 dcg:耐用消费品价格指数 .