import tushare as ts
import pandas as pd
#提取所需要的的hs300里面的数据
hs300 = ts.get_hs300s()['code'].tolist() #tolist 就是把得到的序列变成list
#print(hs300)
#获得基本面数据
#rev:收入同比(%) profit:利润同比 (%) npr:净利润率
stock_basis = ts.get_stock_basics()
stock_basis.reset_index(inplace=True)
data1 = stock_basis.loc[stock_basis['code'].isin(hs300),['code','name','industry','pe','pb','esp','rev','profit']]
data1.columns=['代码','名称','行业',