Hello again to all…sorry for so many questions…I have this script below. Am using jupyter notebook…it is always like this…when i first run, all is fine…but when 2nd run it shows error…pls help check…thanks
the code
###Duplicate @ Y
from collections import defaultdict
import pandas as pd
df = pd.DataFrame(
[
(76, 44),
(32, 45),
(77, 44),
(78, 44),
(78, 34),
(78, 45),
(45, 44),
(87, 54),
(34, 23),
(76, 45),
(54, 58),
(95, 34),
(77, 45),
(84, 45),
], columns=('Y', 'X')
)
entries = defaultdict(list)
for x, y in zip(df.loc[ : , 'X'], df.loc[ : , 'Y']):
entries[x].append(y)
#print('X\tY')
for x, y_list in entries.items():
y_list.sort()
for start in range(len(y_list) - 2):
if y_list[start] == y_list[start + 1] - 1 == y_list[start + 2] - 2:
for y in y_list[start : start + 3]:
test = (f'{y}\t{x}')
print(test)
on second run the error shows below.
TypeError Traceback (most recent call last)
Cell In[3], line 25
3 import pandas as pd
6 df = pd.DataFrame(
7 [
8 (76, 44),
(...)
22 ], columns=('Y', 'X')
23 )
---> 25 entries = defaultdict(list)
27 for x, y in zip(df.loc[ : , 'X'], df.loc[ : , 'Y']):
28 entries[x].append(y)
TypeError: first argument must be callable or None
Hoping for any support…thanks