2016-12-30 9 views
1

F列(青色)の行に#があるときはいつでも、D列(黄色)から文字列を抽出する必要があります。私は初心者で、この仕事のためにパンダとopenpyxlを試していたが運がなかった。これはどちらが良いでしょうか?
保存しておきたいので、後でアクセスできます。
また、H列(緑色)から数値を抽出するのは正規表現で最も簡単でしょうか? Link to onedrive with the excel My workbookPython:別の列の値に基づいてセル値を抽出する

+0

あなたのデータを処理する機会を与えるためのテキストではありません。 –

+0

@NickilMaveliはブックへのリンクを追加しました。ヘッドアップのおかげで –

答えて

1

前に「=」記号を持って、その列を想定します

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 
boolean indexing
+0

これは完璧に動作します、ありがとう –

1

次のコードを使用して、列Fから必要な値を選択できます。 locで選択し

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

そして:また、私はHは、私はあなたがread_excel最初が必要だと思うし、それが最初7行はスキップする必要があると思われる数

import csv 
import pandas as pd 
from io import StringIO 
Excelfile = "file.xlsx" 
df = pd.read_excel(open(Excelfile,'rb'), sheetname='Sheet1') 
selectstring = df['ColumnD'].where(df['ColumnF'] == '#') 
print selectstring 

print df['Columnh'].str.split('=')[1] 
関連する問題