Most efficient way to convert values of column in Pandas DataFrame
<p>I have a a pd.DataFrame that looks like:</p>

<p><a href="https://i.stack.imgur.com/17YRS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/17YRS.png" alt="enter image description here"></a></p>

<p>I want to create a cutoff on the values to push them into binary digits, my cutoff in this case is <code>0.85</code>.  I want the resulting dataframe to look like:</p>

<p><a href="https://i.stack.imgur.com/JKR8o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JKR8o.png" alt="enter image description here"></a></p>

<p>The script I wrote to do this is easy to understand but for large datasets it is inefficient.  I'm sure Pandas has some way of taking care of these types of transformations. </p>

<p><strong>Does anyone know of an efficient way to convert a column of floats to a column of integers using a threshold?</strong> </p>

<p>My extremely naive way of doing such a thing:</p>

<pre><code>DF_test = pd.DataFrame(np.array([list("abcde"),list("pqrst"),[0.12,0.23,0.93,0.86,0.33]]).T,columns=["c1","c2","value"])
DF_want = pd.DataFrame(np.array([list("abcde"),list("pqrst"),[0,0,1,1,0]]).T,columns=["c1","c2","value"])


threshold = 0.85

#Empty dataframe to append rows
DF_naive = pd.DataFrame()
for i in range(DF_test.shape[0]):
    #Get first 2 columns
    first2cols = list(DF_test.ix[i][:-1])
    #Check if value is greater than threshold
    binary_value = [int((bool(float(DF_test.ix[i][-1]) &gt; threshold)))]
    #Create series object
    SR_row = pd.Series( first2cols + binary_value,name=i)
    #Add to empty dataframe container
    DF_naive = DF_naive.append(SR_row)
#Relabel columns
DF_naive.columns = DF_test.columns
DF_naive.head()
#the sample DF_want
</code></pre>