2021-12-24 15:24:26 +08:00
|
|
|
import json
|
|
|
|
import pandas as pd
|
|
|
|
|
2021-12-21 11:06:58 +08:00
|
|
|
from company.db import find_data_in_company
|
2021-12-13 16:04:10 +08:00
|
|
|
|
|
|
|
|
2021-12-21 11:06:58 +08:00
|
|
|
def find_company_data_scripts(table, cid):
|
|
|
|
return find_data_in_company(table, {"企业ID": cid})
|
2021-12-24 15:24:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
def find_financial_index_detail_scripts(table, cid):
|
|
|
|
df = pd.DataFrame(find_data_in_company(table, {"企业ID": cid})).sort_values('年报期', ascending=False)
|
|
|
|
cols = [
|
|
|
|
'年报期',
|
|
|
|
'净资产收益率',
|
|
|
|
'总资产报酬率',
|
|
|
|
'总资产周转率',
|
|
|
|
'应收账款周转率',
|
|
|
|
'存货周转率',
|
|
|
|
'资产负债率',
|
|
|
|
'已获利息倍数',
|
|
|
|
'速动比率',
|
|
|
|
'营业增长率',
|
|
|
|
'总资产增长率',
|
|
|
|
'技术投入比率'
|
|
|
|
]
|
|
|
|
unit_cols = [
|
|
|
|
'净资产收益率',
|
|
|
|
'总资产报酬率',
|
|
|
|
'总资产周转率',
|
|
|
|
'存货周转率',
|
|
|
|
'资产负债率',
|
|
|
|
'速动比率',
|
|
|
|
'营业增长率',
|
|
|
|
'总资产增长率',
|
|
|
|
'技术投入比率'
|
|
|
|
]
|
|
|
|
|
|
|
|
def percent_unit(param):
|
|
|
|
return param.map(lambda x: '{}%'.format(x) if (param.name in unit_cols and not pd.isna(x)) else x)
|
|
|
|
|
|
|
|
df_result = df[cols].apply(lambda x: percent_unit(x))
|
|
|
|
|
|
|
|
return list(json.loads(df_result.T.to_json()).values())
|