How does numpy handle data files with uncertainty values, e.g., 0.6499(6)?
<p>Here is a snippet of a large data set I am working with:</p>

<pre><code># p*  T*     P*         U*          P*_cs    U*_cs  Steps  dt*
0.1   6.0    0.6499(6) -0.478(2)    0.6525  -0.452  30000  0.002
0.2   6.0    1.442(1)  -0.942(2)    1.452   -0.890  30000  0.002
0.3   6.0    2.465(3)  -1.376(1)    2.489   -1.298  30000  0.002
0.4   6.0    3.838(5)  -1.785(3)    3.880   -1.681  20000  0.002
0.5   6.0    5.77(1)   -2.131(3)    5.84    -2.000  20000  0.002
0.6   6.0    8.51(2)   -2.382(5)    8.60    -2.225  20000  0.002
0.7   6.0   12.43(2)   -2.501(4)   12.56    -2.318  20000  0.002
0.8   6.0   18.05(2)   -2.416(4)   18.22    -2.207  20000  0.002
0.9   6.0   26.00(2)   -2.058(4)   26.21    -1.823  20000  0.004
1.0   6.0   37.06(3)   -1.361(6)   37.32    -1.100  20000  0.002
1.1   6.0   52.25(2)   -0.216(4)   52.57     0.072  20000  0.002
1.2   6.0   72.90(5)    1.502(9)   73.28     1.816  20000  0.002
1.25  6.0   85.71(5)    2.612(8)   86.12     2.939  20000  0.002
</code></pre>

<p>Loading in this data set using <code>np.loadtxt</code> fails because of the uncertainties for the P* and U* values.  Is there a built-in tool for handling this to avoid manually editing the data files? </p>

<p>I am looking at the <a href="https://pythonhosted.org/uncertainties/numpy_guide.html" rel="nofollow">uncertainties</a> package as a possible solution but I wonder if numpy already has something for this.</p>

<p>No, there is nothing like that in NumPy.  You will either need an external package (even Pandas won't do it), or you can load the columns as strings instead of numbers and process them yourself.  For the string approach, the <code>str</code> methods in Pandas would be of some use, e.g. <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.split.html" rel="nofollow">http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.split.html</a></p>

<p>All that said, it's not even clear how you would want to represent this once the data are loaded.  Do you want to simply ignore the parentheses?  Do you want to record the number of uncertain digits in an additional column?  Both are possible, and probably easier in Pandas than NumPy.</p>

python numpy uncertainty