-
Notifications
You must be signed in to change notification settings - Fork 1
/
deaAnayisis.py
74 lines (63 loc) · 2.82 KB
/
deaAnayisis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""
Created on *********
@author: 了不起的田所李
"""
import pydea
import matplotlib as plt
import pandas as pd
import numpy as np
import sys
stockNum = str(sys.argv[1])
try:
#读取csv文件
data = pd.read_csv("./Assets_and_liabilities/" + stockNum + ".csv", encoding="utf-8")
except UnicodeDecodeError:
data = pd.read_csv("./Assets_and_liabilities/" + stockNum + ".csv", encoding="gbk")
# 资产总计
total_assets = data.iloc[46, ]
# 负债合计
total_liabilities = data.iloc[80, :]
# 所有者权益
owners_equity = data.iloc[81, :]
# 营业总成本
data_total_operating_costs = pd.read_csv("./Total_operating_costs/" + stockNum + "-profit.csv", encoding="utf-8")
total_operating_costs = data_total_operating_costs.iloc[3, :]
# 筹资活动的现金流入量
data_Funds_inflow_for_financing_activities = pd.read_csv("./Funds_inflow_for_financing_activities/"
+ stockNum + "-flow.csv", encoding="utf-8")
funds_inflow_for_financing_activities = data_Funds_inflow_for_financing_activities.iloc[32, :]
# 营业收入
operating_income = data_total_operating_costs.iloc[2, :]
# 净利润
profit = data_total_operating_costs.iloc[21, :]
# 输入数据合并
inputData = pd.concat([total_assets, total_liabilities, owners_equity, total_operating_costs,
funds_inflow_for_financing_activities], axis=1, sort=False)
# inputData.rename(columns={'46':'资产总计','80':'负债合计', "81":'所有者权益', '3':'营业总成本', '32':'偿还债务支付的现金'})
inputData = inputData.iloc[1:, :].astype("float64")
inputData = inputData.fillna(value=0)
# print(inputData)
outputData = pd.concat([operating_income, profit], axis=1, sort=False)
# outputData = outputData.rename(columns={'2':'营业收入','21':'净利润'})
outputData = outputData.iloc[1:, :].astype("float64")
outputData = outputData.fillna(value=0)
# print(outputData)
#执行计算
uni_prob_CRS = pydea.DEAProblem(inputData, outputData, returns='CRS')
myresults_CRS = uni_prob_CRS.solve()
#执行计算
uni_prob_VRS = pydea.DEAProblem(inputData, outputData, returns='VRS')
myresults_VRS = uni_prob_VRS.solve()
# myresults_CRS['综合效率'] = myresults_CRS['Efficiency']
# myresults_VRS['纯技术效率'] = myresults_VRS['Efficiency']
myresults = pd.DataFrame()
myresults['综合效率'] = myresults_CRS['Efficiency']
myresults['CRS_Status'] = myresults_CRS['Status']
myresults['纯技术效率'] = myresults_VRS['Efficiency']
myresults['VRS_Status'] = myresults_VRS['Status']
myresults['规模效率'] = (myresults_CRS['Efficiency'] / myresults_VRS['Efficiency']).fillna(0)
# myresults
# myresults['规模效率']
# 输出数据
myresults.to_csv("DeaResultFrom" + stockNum + ".csv", encoding="utf_8_sig")