Python: Difficulties with converting negative strings numbers into floats
Question: I have been trying to figure this out for hours now. I have this list that I
need converted to a float so I can use it in `numpy.corrceof()` along with
another identical list.

The list, `r` is as follows:

    
    
    >>> print r
    [-0.6680161943319838, -0.7236994219653179, -0.7088915956151035, -0.7388949079089924, -0.7149712092130518, -0.6123110151187905, -0.39853300733496333, -0.017366136034732287, -0.1457800511508952, 0.03546099290780142, 0.0319573901464714, 0.3491027732463295, 0.03203342618384407, 0.2081005586592179, 0.014833127317676267, 0.32045779685264664, 0.31069182389937106, -0.06653225806451614, -0.15583075335397314, -0.2147727272727273, 0.03030303030303036, -0.10076530612244898, -0.2888257575757576, 0.1227106227106227, 0.7095238095238093, 2.808510638297873, 3.7588235294117647, 3.4240506329113924, 4.264900662251656, 5.1234567901234565, 6.34090909090909, 5.666666666666667, 4.163265306122449, 3.611764705882353, 5.439024390243903, 1.9197860962566844, 1.1649484536082475, -0.04081632653061228, -0.17874396135265697, -0.20999999999999996, -0.277511961722488, -0.20197044334975356, -0.2189349112426035, 0.2222222222222222, 0.4134615384615384, 0.47826086956521746, 0.23308270676691714, 0.6120689655172415, 0.9795918367346939, 1.0851063829787235, 1.0294117647058822, 0.6666666666666667, 1.1546391752577319, 1.2065217391304346, 0.69, 0.10204081632653071, -0.009523809523809532, -0.16666666666666666, -0.14193548387096772, -0.24675324675324684, -0.16949152542372878, -0.276923076923077, 0.020000000000000018, 0.7142857142857143, -0.5446009389671361, -0.7401129943502825, -0.7858672376873662, -0.8171641791044777, -0.8, -0.7320388349514564, -0.7327586206896552, -0.7555555555555555, -0.8284883720930233, -0.7833333333333333, -0.8144712430426716, -0.8809523809523809, -0.6120218579234973, -0.33831775700934574, -0.2203672787979967, -0.08688245315161836, -0.19230769230769232, 0.030000000000000072, 0.13725490196078435, 0.24752475247524752, 0.4012219959266802, 0.22448979591836726, 0.19777777777777772, 0.3213483146067415, 0.30714285714285716, 0.5735294117647058, 0.8151515151515153, 0.834375, 1.3636363636363635, 0.7301038062283737, 0.5692307692307691, 0.3015463917525773, 0.6098360655737707, 0.4202898550724638, 0.0975609756097562, 0.6360294117647058, 0.9090909090909091, 0.36, 0.5865384615384615, 0.787709497206704, 1.5943396226415094, 1.7264150943396226, 2.25, 2.88, 1.9901960784313724]
    >>> type(r)
    <type 'str'>
    >>> print len(r)
    2169
    

When I try to perform `float(r)`:

    
    
    >>> float(r)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: could not convert string to float: [-0.6680161943319838, -0.7236994219653179, -0.7088915956151035, -0.7388949079089924, -0.7149712092130518, -0.6123110151187905, -0.39853300733496333, -0.017366136034732287, -0.1457800511508952, 0.03546
    

From previous questions, I have seen that empty values `""` could cause the
issue. However I have no idea why there would be an empty value in the list.
Even at that, I've tried numerous methods from other questions, like
converting the `list` to an `numpy.array`, then using `s = r[r=='']='0'`.
However this _still_ does not work.

Anyone have any tips?

# Bonus:

Why is `len(r)` `== 2169?` The code I run to build the list only makes lists
of exactly `121` values. If you actually count the list, there are 121 values
there... Can anyone explain this?


Answer: The string is a JSON string representing a list of floats.

    
    
    import json
    data = json.loads(r)
    

