Hello i have a series of bool values where i have performed logical operations on them since they are series i have used & instead of and here are the series
z = ~(df['HOME ZIP'].isin(zip_series['zipcd_ZIP_CD']))
here is type of z
type(z)
pandas.core.series.Series
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 False
10 False
11 False
12 False
13 False
14 False
15 False
16 False
17 False
18 False
19 False
20 False
21 False
22 False
23 False
24 False
25 False
26 False
27 False
28 False
29 False
30 False
Name: HOME ZIP, dtype: bool
similarly
y = df['HOME ZIP'].astype(str).str.len() != 0
x = (df['HOME ZIP'].isnull() == False)
values of x and y are both True
0 True
1 True
2 True
3 True
4 True
5 True
6 True
7 True
8 True
9 True
10 True
11 True
12 True
13 True
14 True
15 True
16 True
17 True
18 True
19 True
20 True
21 True
22 True
23 True
24 True
25 True
26 True
27 True
28 True
29 True
30 True
Name: HOME ZIP, dtype: bool
x & y & z values are here
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 False
10 False
11 False
12 False
13 False
14 False
15 False
16 False
17 False
18 False
19 False
20 False
21 False
22 False
23 False
24 False
25 False
26 False
27 False
28 False
29 False
30 False
Name: HOME ZIP, dtype: bool
but when i keep all x y,z as single statements i am getting different output
(df['HOME ZIP'].isnull() == False) & df['HOME ZIP'].astype(str).str.len() != 0 & ~(df['HOME ZIP'].isin(zip_series['zipcd_ZIP_CD']))
0 True
1 True
2 True
3 True
4 True
5 True
6 True
7 True
8 True
9 True
10 True
11 True
12 True
13 True
14 True
15 True
16 True
17 True
18 True
19 True
20 True
21 True
22 True
23 True
24 True
25 True
26 True
27 True
28 True
29 True
30 True
Name: HOME ZIP, dtype: bool
CodePudding user response:
You should add ()
for each condition
(df['HOME ZIP'].isnull() == False) &
(df['HOME ZIP'].astype(str).str.len() != 0) &
(~(df['HOME ZIP'].isin(zip_series['zipcd_ZIP_CD'])))