How do I keep only first 20 rows in a DataFrame and export it to a new DataFrame variable? in one line
-
first(df, 20)
if you want to produce 20 or less rows (if data frame is shorter). -
df[1:20, :]
if you want to produce 20 rows or throw error if data frame is shorter.
6 Likes