Pandas data frame preview: df.head and df.sample

Pandas data frame preview: df.head and df.sample

Want to get a quick look at a Python Pandas data frame you just created?

Option 1, use df.head(n) to look at the first n rows:

df.head(5)  # first 5 rows

Option 2, use df.sample(n) to look at n randomly selected rows:

df.sample(5)  # 5 random rows