I have a dataframe that looks like this:
In [169]: dfstacked
Out[169]:
Percent Held Rank
0 14.10 [1]
1 11.13 [2]
2 10.11 [3]
3 8.99 [4]
4 4.79 [5]
5 2.92 [6]
6 2.79 [7]
7 2.63 [8]
8 2.63 [9]
9 1.83 [10]
10 1.81 [11]
11 1.66 [12]
12 1.66 [13]
13 1.64 [14]
14 1.63 [15]
15 1.62 [16]
16 1.26 [17]
17 1.08 [18]
18 1.08 [19]
19 1.07 [20]
The underlying datatype of dfstacked["Rank"] is array. I created it using a regex (using str.findall()), but to be safe I check:
In [171]: dfstacked["Rank"].dtype
Out[171]: dtype('O')
However, I want to cast dfstacked["Rank"] to an Series with int datatype so that I can perform some statistical tests on the values in dfstacked["Rank"]. How would I go about doing this?
So far I have tried to force an integer Series using Series.map and Series.astype(). Both return ValueErrors.
Ultimately, I want
Percent Held Rank
0 14.10 1
1 11.13 2
2 10.11 3
3 8.99 4
4 4.79 5
5 2.92 6
6 2.79 7
7 2.63 8
8 2.63 9
9 1.83 10
10 1.81 11
11 1.66 12
12 1.66 13
13 1.64 14
14 1.63 15
15 1.62 16
16 1.26 17
17 1.08 18
18 1.08 19
19 1.07 20
Rankcolumn: one-element lists or strings like'[1]'