Is there a more pythonic way to write this?
<p>I'm looking to make this a little more pythonic.</p>

<pre><code>user_df[-1:]['status_id'].values[0] in {3,5}
</code></pre>

<p>I ititially tried <code>user_id.ix[-1:, 'status_id'].isin([3,5])</code>, but didn't work.</p>

<p>Any suggestions? The top version works, but looks a little weird.</p>

<p><code>isin</code> might be marginally faster (the more values that you have to check the more speed up you would notice ... but even for large sets its not going to be a huge difference ...(I doubt its any faster in this example... its probably a little slower) ... but <code>val in set()</code> <strong>is pretty dang pythonic</strong> (in fact much more so than <code>pd.isin</code>)</p>

<p>you are testing a <strong>single value</strong> against a <code>set</code> ... by using <code>pandas.isin</code> or <code>numpy.in1d</code> you will incure significant time overhead to move into C and back to python vs just using <code>in</code> and a set wich is an <code>O(1)</code> look up ... (<em>in either case the time slice is non-existent on a human time scale</em>)</p>

python pandas