请帮我为ai替代率匹配投资水平、敏捷程度和高管背景,这三个都开一列,匹配的条件是年份和股票代码,对于...

创建于:2025年6月17日

使用 O3 回答 Chat01

问题

A股上市公司人工智能投资水平(剔除st及金融).xlsx
企业ai替代率.xls
敏捷度.xlsx
高管数字化背景.xlsx

请帮我为ai替代率匹配投资水平、敏捷程度和高管背景,这三个都开一列,匹配的条件是年份和股票代码,对于没有的数值不用赋值,提供供我直接下载的表格形式

Python

python
files = [ "/mnt/data/A股上市公司人工智能投资水平(剔除st及金融).xlsx", "/mnt/data/企业ai替代率.xls", "/mnt/data/敏捷度.xlsx", "/mnt/data/高管数字化背景.xlsx" ] for f in files: print(f, os.path.exists(f))

Python

python
dfs = {} for f in files: try: df = pd.read_excel(f) except Exception as e: print("Error loading", f, e) continue print(f, df.shape) print(df.head()) dfs[f] = df

Python

python
try: df_ai = pd.read_excel("/mnt/data/企业ai替代率.xls", engine='xlrd') except Exception as e: print("error", e)

Python

python
try: import openpyxl, warnings, traceback, math, numpy as np

Python

python
try: df_ai = pd.read_excel("/mnt/data/企业ai替代率.xls", engine='openpyxl') except Exception as e: print("openpyxl error", e)

Python

python
try: import xlrd print(xlrd.__version__) except Exception as e: print("cannot import xlrd", e)

Python

python
with open("/mnt/data/企业ai替代率.xls", "rb") as f: header = f.read(8) print(header)

Python

python
!pip -q install xlrd

Python

python
os.listdir('/mnt/data') ['A股上市公司人工智能投资水平(剔除st及金融).xlsx', '敏捷度.xlsx', '企业ai替代率.xls', '高管数字化背景.xlsx']

Python

python
print(dfs['/mnt/data/敏捷度.xlsx'].columns)

Python

python
df_exec = dfs['/mnt/data/高管数字化背景.xlsx'] print(df_exec.head()) print(df_exec.columns)

思考

I’m looking through the investment and agile files. For the investment file, there seems to be a formatting issue with the '证券代码' column, which should be '000002' instead of just '2.' As for the agile file, I’m seeing 'symbol,' 'year,' 'board,' and 'stock' columns that represent agility data—maybe board-level metrics? Since the user just wants to add the file’s measure as a new column, I’ll check the ‘敏捷度’ sheet for any computed agility metrics and possibly calculate the mean of board and stock data.

Thought for 5m 35s

回答

我已成功读取 《A股上市公司人工智能投资水平(剔除ST及金融).xlsx》、 《敏捷度.xlsx》 和 《高管数字化背景.xlsx》,但目前无法解析 《企业ai替代率.xls》 ——这是旧版 .xls 格式,需要 xlrd 类库,而当前运行环境里无法安装新依赖。

为了给您做出按“年份 + 股票代码”匹配、并生成可下载的完整表格(含“投资水平”“敏捷度”“高管数字化背景”三列),烦请您把 《企业ai替代率》 文件另存为 .xlsx 或 .csv 后重新上传。收到新版文件后,我就能一次性帮您合并并提供下载链接。谢谢!

分享这个问答