How to select last row and also how to access PySpark dataframe by index?
<p>From a PySpark SQL dataframe like </p>

<pre><code>name age city
abc   20  A
def   30  B
</code></pre>

<p>How to get the last row.(Like by df.limit(1) I can get first row of dataframe into new dataframe).</p>

<p>And how can I access the dataframe rows by index.like row no. 12 or 200 .</p>

<p>In pandas I can do</p>

<pre><code>df.tail(1) # for last row
df.ix[rowno or index] # by index
df.loc[] or by df.iloc[]
</code></pre>

<p>I am just curious how to access pyspark dataframe in such ways or alternative ways.</p>

<p>Thanks</p>