Python:根据另一列中的值提取单元格值

标签 python excel pandas indexing openpyxl

每当 F 列(蓝色)中的一行中有 # 时,我需要从 D 列(黄色)中提取字符串。我是一个初学者,正在尝试使用 Pandas 和 openpyxl 来完成这项任务,但没有运气。哪一个更适合这个?
我希望存储它们,以便以后可以访问它们。
另外,使用正则表达式从 H 列(绿色)中提取数字是最简单的吗? Link to onedrive with the excel My workbook

最佳答案

我认为你需要read_excel首先,似乎必须跳过前 7 行:

df = pd.read_excel('LTE_KPIs_up.xlsx', skiprows=7)
#print (df)

然后选择locboolean indexing :

print (df.loc[df.Unit == '#', 'KPI name'])
0            UE-triggered ERAB Setup Attempts
1           UE-triggered ERAB Setup Successes
4           MME-initiated ERAB Setup Attempts
5          MME-initiated ERAB Setup Successes
8      eNodeB-initiated ERAB Release Attempts
9                 eNodeB-initiated ERAB Drops
11        MME-initiated ERAB Release Attempts
12                   MME-initiated ERAB Drops
14                 ERAB Modification Attempts
15                ERAB Modification Successes
18                    HO Preparation Attempts
19                   HO Preparation Successes
22            HO Resource Allocation Attempts
23           HO Resource Allocation Successes
26                          Handover Attempts
27                         Handover Successes
33                        EPS Attach Attempts
34                       EPS Attach Successes
37                        EPS Detach Attempts
38                       EPS Detach Successes
40                EPS Authentication Attempts
41               EPS Authentication Successes
43                EPS Security Setup Attempts
44               EPS Security Setup Successes
46                 EMM Identification Attepmt
47               EMM Identification Successes
49              EPS Service Request Attemptss
50              EPS Service Request Successes
52              Tracking Area Update Attempts
53             Tracking Area Update Successes

117       S6a Delete Subscriber Data Attempts
118      S6a Delete Subscriber Data Successes
120                 S6a Notification Attempts
121                S6a Notification Successes
126               S11 Create Session Attempts
127              S11 Create Session Successes
130                S11 Create Bearer Attempts
131               S11 Create Bearer Successes
134                S11 Update Bearer Attempts
135               S11 Update Bearer Successes
138             Modify Access Bearer Attempts
139            Modify Access Bearer Successes
141            Release Access Bearer Attempts
142           Release Access Bearer Successes
144       Downlink Data Notification Attempts
145      Downlink Data Notification Successes
147               S11 Delete Session Attempts
148              S11 Delete Session Successes
150                S11 Delete Bearer Attempts
151               S11 Delete Bearer Successes
154                          Suspend Attempts
155                         Suspend Successes
157                           Resume Attempts
158                          Resume Successes
162                ME Identity Check Attempts
163               ME Identity Check Successes
168           Credit Control Initial Attempts
169          Credit Control Initial Successes
171       Credit Control Termination Attempts
172      Credit Control Termination Successes
Name: KPI name, dtype: object

关于Python:根据另一列中的值提取单元格值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41397901/

相关文章:

python - 从正态分布中进行拉丁超立方采样 (Python)

python - 在 Python 中对稀疏数据集进行过采样

python - Django - 如何以最佳方式编写用户和配置文件处理?

xml - 寻找 Excel 的 .xlsx XML 格式的清晰描述

arrays - 在 VBA 函数中访问各个数组元素

python - "-inf "在python中是什么意思?

python - OperationalError : (OperationalError) (2003, "Can' t 连接到 '192.168.129.139' (111)"上的 MySQL 服务器"无 无

c# - 使用 C# Interop 从 Excel 中以明文形式获取所有工作表名称?

python - 计算具有特定值的一行之后的两行

python-3.x - 在 Pandas 中使用 groupby 获取行数