How to select last row and also how to access PySpark dataframe by index?
问题 From a PySpark SQL dataframe like name age city abc 20 A def 30 B How to get the last row.(Like by df.limit(1) I can get first row of dataframe into new dataframe). And how can I access the dataframe rows by index.like row no. 12 or 200 . In pandas I can do df.tail(1) # for last row df.ix[rowno or index] # by index df.loc[] or by df.iloc[] I am just curious how to access pyspark dataframe in such ways or alternative ways. Thanks 回答1: How to get the last row. Long and ugly way which assumes