In Pandas, how do you access the first five rows of a DataFrame?
- df.head()
- df.iloc[:5]
- df.loc[:5]
- df[0:5]
To access the first five rows of a Pandas DataFrame, you should use the head() method, like df.head(). This method returns the top N rows (default is 5) of the DataFrame.
Loading...
Related Quiz
- Which Python feature allows functions to accept any number of keyword arguments?
- Python's reference implementation is known as _______.
- When reading a file in text mode in Python, what does the file method readline() return?
- What is the difference between is and == when comparing variables in Python?
- How can you annotate a specific point on a plot in Matplotlib?