I have an a pandas series with an array as value for each like so:
'Node'
.. ....
97 [355.0, 296.0]
98 [53.0, 177.0]
99 [294.0, 14.0]
100 [330.0, 15.0]
101 [100.0, 160.0]
102 [10.0, 220.0]
103 [330.0, 290.0]
I want to find the index of all the rows that contain the value 330.0, which would be 100 and 103.
What I have tried until now is:
vals = [item for item in df.Node if item[0] == 330.0]
which gives me [array([ 330., 15.]), array([ 330., 290.])]
and then:
for val in vals:
id = pd.Index(df.Node).get_loc(val)
This throws an error saying TypeError: '[ 330. 15.]' is an invalid key
How do I solve this and get the row index of the value?
Edit : Here's a sample dataframe with much fewer rows.
0 [139.0, 105.0]
1 [290.0, 200.0]
2 [257.0, 243.0]
3 [235.0, 7.0]
4 [12.0, 115.0]
5 [168.0, 135.0]
6 [105.0, 258.0]
7 [339.0, 64.0]
8 [6.0, 148.0]
9 [33.0, 286.0]
10 [62.0, 26.0]
11 [307.0, 185.0]
12 [34.0, 269.0]
13 [206.0, 60.0]
14 [327.0, 127.0]
15 [127.0, 202.0]
16 [297.0, 48.0]
17 [131.0, 151.0]
18 [326.0, 1.0]
19 [304.0, 35.0]
20 [329.0, 23.0]
21 [314.0, 287.0]
22 [1.0, 233.0]
23 [260.0, 280.0]
24 [313.0, 56.0]
25 [294.0, 33.0]
26 [243.0, 256.0]
27 [151.0, 174.0]
28 [271.0, 295.0]
29 [141.0, 184.0]
30 [105.0, 157.0]
31 [288.0, 269.0]
32 [118.0, 210.0]
33 [38.0, 194.0]
34 [49.0, 154.0]
35 [40.0, 204.0]
36 [317.0, 27.0]
37 [359.0, 33.0]
38 [56.0, 184.0]
39 [359.0, 39.0]
40 [48.0, 170.0]
41 [314.0, 51.0]
42 [175.0, 184.0]
43 [28.0, 200.0]
44 [35.0, 169.0]
45 [330.0, 15.0]
46 [100.0, 160.0]
47 [10.0, 220.0]
48 [330.0, 290.0]
Name: Node, dtype: object