I am trying to filter some info eg Name from a table and print it, but seems like my code is not working.
followed eg in
http://pbpython.com/excel-pandas-comp-2.html and still not working.
import pandas as pd
import numpy as np
all_dataB = pd.DataFrame()
dfB= pd.read_excel("C:\File2.xlsx")
dfB[dfB["BoardName"]=='Alex*']
all_dataB = dfB
print(dfB)#check
Please explain not working.
How far do you get before a fail
Please post entire error traceback, it contains important information
Have you installed pandas?
Have you installed xlrd?
Have you checked to make sure a file named 'File2.xlsx' exists in C:\
(Dec-28-2017, 11:58 AM)Larz60+ Wrote: [ -> ]Please explain not working.
How far do you get before a fail
Please post entire error traceback, it contains important information
Have you installed pandas?
Have you installed xlrd?
Have you checked to make sure a file named 'File2.xlsx' exists in C:\
modules are installed.
i can print the result but it is not filtered, it was exactly same as input file. No errors message.
tired on conda mini as well, code is not working.
Could you attach a sample of File2.xlsx
so that it can be run here?
remove the c:\ fro m file name
import pandas as pd
import numpy as np
all_dataB = pd.DataFrame()
dfB= pd.read_excel("File2.xlsx")
dfB[dfB["BoardName"]=='Alex*']
all_dataB = dfB
print(dfB)#check
results:
Output:
Backend TkAgg is interactive backend. Turning interactive mode on.
AreaName BoardName
0 Utopia Darren
1 Utopia Alex
2 Utopia Alex
3 Utopia Alex
4 Utopia Alex
5 Utopia Alex
6 Utopia Alex
7 Utopia Alex
8 Utopia Alex
9 Utopia Alex
10 Utopia Alex
11 Utopia Alex
12 Utopia Darren
13 Utopia Darren
14 Utopia Darren
15 Utopia Sean
16 Utopia MRRU
17 Utopia MRRU
18 Utopia MRRU
19 Utopia MRRU
20 Utopia MRRU
21 Utopia MRRU
22 Utopia Alex
23 Utopia Alex
24 Utopia Alex
25 Utopia Alex
26 Japan MRRU
27 Japan MRRU
28 Japan MRRU
29 Japan Alex
.. ... ...
128 Japan MRRU
129 Japan MRRU
130 Indonesia Darren
131 Indonesia Alex
132 Indonesia Darren
133 Indonesia Darren
134 Indonesia Sean
135 Indonesia MRRU
136 Indonesia MRRU
137 Indonesia MRRU
138 Indonesia MRRU
139 Indonesia MRRU
140 Indonesia MRRU
141 Indonesia Alex
142 Indonesia Alex
143 Indonesia Alex
144 Indonesia Alex
145 Indonesia Alex
146 Indonesia Alex
147 Indonesia Alex
148 Indonesia Alex
149 Indonesia Alex
150 Indonesia Alex
151 Indonesia Alex
152 Indonesia Darren
153 Cebu Darren
154 Cebu Darren
155 Cebu Sean
156 Cebu Alex
157 Cebu MRRU
[158 rows x 2 columns]
(Jan-08-2018, 11:28 AM)Larz60+ Wrote: [ -> ]remove the c:\ fro m file name import pandas as pd import numpy as np all_dataB = pd.DataFrame() dfB= pd.read_excel("File2.xlsx") dfB[dfB["BoardName"]=='Alex*'] all_dataB = dfB print(dfB)#check
results: Output:
Backend TkAgg is interactive backend. Turning interactive mode on. AreaName BoardName 0 Utopia Darren 1 Utopia Alex 2 Utopia Alex 3 Utopia Alex 4 Utopia Alex 5 Utopia Alex 6 Utopia Alex 7 Utopia Alex 8 Utopia Alex 9 Utopia Alex 10 Utopia Alex 11 Utopia Alex 12 Utopia Darren 13 Utopia Darren 14 Utopia Darren 15 Utopia Sean 16 Utopia MRRU 17 Utopia MRRU 18 Utopia MRRU 19 Utopia MRRU 20 Utopia MRRU 21 Utopia MRRU 22 Utopia Alex 23 Utopia Alex 24 Utopia Alex 25 Utopia Alex 26 Japan MRRU 27 Japan MRRU 28 Japan MRRU 29 Japan Alex .. ... ... 128 Japan MRRU 129 Japan MRRU 130 Indonesia Darren 131 Indonesia Alex 132 Indonesia Darren 133 Indonesia Darren 134 Indonesia Sean 135 Indonesia MRRU 136 Indonesia MRRU 137 Indonesia MRRU 138 Indonesia MRRU 139 Indonesia MRRU 140 Indonesia MRRU 141 Indonesia Alex 142 Indonesia Alex 143 Indonesia Alex 144 Indonesia Alex 145 Indonesia Alex 146 Indonesia Alex 147 Indonesia Alex 148 Indonesia Alex 149 Indonesia Alex 150 Indonesia Alex 151 Indonesia Alex 152 Indonesia Darren 153 Cebu Darren 154 Cebu Darren 155 Cebu Sean 156 Cebu Alex 157 Cebu MRRU [158 rows x 2 columns]
my desire result should contains Alex only.
import pandas as pd
all_datab = pd.DataFrame()
dfb = pd.read_excel("File2.xlsx")
dfc = dfb[dfb["BoardName"] == 'Alex']
print(dfc)
Results:
Output:
AreaName BoardName
1 Utopia Alex
2 Utopia Alex
3 Utopia Alex
4 Utopia Alex
5 Utopia Alex
6 Utopia Alex
7 Utopia Alex
8 Utopia Alex
9 Utopia Alex
10 Utopia Alex
11 Utopia Alex
22 Utopia Alex
23 Utopia Alex
24 Utopia Alex
25 Utopia Alex
29 Japan Alex
30 Japan Alex
31 Japan Alex
32 Japan Alex
33 Japan Alex
34 Japan Alex
35 Japan Alex
36 Japan Alex
37 Japan Alex
38 Japan Alex
39 Japan Alex
40 Japan Alex
52 Indonesia Alex
62 Indonesia Alex
63 Indonesia Alex
.. ... ...
90 Utopia Alex
101 Utopia Alex
102 Utopia Alex
103 Utopia Alex
104 Utopia Alex
108 Japan Alex
109 Japan Alex
110 Japan Alex
111 Japan Alex
112 Japan Alex
113 Japan Alex
114 Japan Alex
115 Japan Alex
116 Japan Alex
117 Japan Alex
118 Japan Alex
119 Japan Alex
131 Indonesia Alex
141 Indonesia Alex
142 Indonesia Alex
143 Indonesia Alex
144 Indonesia Alex
145 Indonesia Alex
146 Indonesia Alex
147 Indonesia Alex
148 Indonesia Alex
149 Indonesia Alex
150 Indonesia Alex
151 Indonesia Alex
156 Cebu Alex
[80 rows x 2 columns]