Python pandas check if the last element of a list in a cell contains specific string
<pre><code>my dataframe df:

index                        url
1           [{'url': 'http://bhandarkarscollegekdp.org/'}]
2             [{'url': 'http://cateringinyourhome.com/'}]
3                                                     NaN
4                  [{'url': 'http://muddyjunction.com/'}]
5                       [{'url': 'http://ecskouhou.jp/'}]
6                     [{'url': 'http://andersrice.com/'}]
7       [{'url': 'http://durager.cz/'}, {'url': 'http:andersrice.com'}]
8            [{'url': 'http://milenijum-osiguranje.rs/'}]
9       [{'url': 'http://form-kind.org/'}, {'url': 'https://osiguranje'},{'url': 'http://beseka.com.tr'}]
</code></pre>

<p>I would like to select the rows if the last item in the list of the row of url column contains 'https', while skipping missing values.</p>

<p>My current script </p>

<pre><code>df[df['url'].str[-1].str.contains('https',na=False)]
</code></pre>

<p>returns False values for all the rows while some of them actually contains https. </p>

<p>Can anybody help with it?</p>

<p>not sure url is str or other types</p>

<p>you can do like this:</p>

<pre><code>"https" in str(df.url[len(df)-1])
</code></pre>

<p>or </p>

<pre><code>str(df.ix[len(df)-1].url).__contains__("https")
</code></pre>

python loops pandas contain