尾巴

返回最後 num 幾列的列表 Row

語法

tail(num: int)

參數

參數 類型 說明
num int 要傳回的記錄數目。 若資料框架記錄數少於此數,則回傳此數或所有記錄。

退貨

列表:列列表。

Notes

尾尾執行需要將資料移入應用程式的驅動程序,若如此,使用非常大的 num 可能會因 OutOfMemoryError 導致驅動程式當機。

Examples

df = spark.createDataFrame(
    [(14, "Tom"), (23, "Alice"), (16, "Bob")], ["age", "name"])

df.tail(2)
# [Row(age=23, name='Alice'), Row(age=16, name='Bob')]