replace certain number in DataFrame
<p>I am pretty new to Python programming and have a question about replacing certain conditional number in a DataFrame. 
for example, I have a dateframe with 5 days of data in each column, day1, day2, day3, day4 and day5. For each day, I have 5 data points with some of them larger than 5 for each day. Now I want to set the data which is larger than 5 to 1. 
So how can I do that? Loop into each column and find specific element then change it, or there is other faster way to do it?
Thanks,</p>

<p>To do this without looping (which is usually faster) you can do:</p>

<pre><code>df[df &gt; 5] = 1
</code></pre>

python pandas replace dataframe