Input: DataFrame employees
+-------------+-----------+-----------------------+--------+| employee_id | name | department | salary |+-------------+-----------+-----------------------+--------+|3| Bob | Operations |48675||90| Alice | Sales |11096||9| Tatiana | Engineering |33805||60| Annabelle | InformationTechnology |37678||49| Jonathan | HumanResources |23793||43| Khaled | Administration |40454|+-------------+-----------+-----------------------+--------+Output:
+-------------+---------+-------------+--------+| employee_id | name | department | salary |+-------------+---------+-------------+--------+|3| Bob | Operations |48675||90| Alice | Sales |11096||9| Tatiana | Engineering |33805|+-------------+---------+-------------+--------+Explanation:
Only the first 3 rows are displayed.## Solution
### Method 1โ DataFrame Head
#### Intuition
To display the first three rows of a DataFrame, we use the `head()` method in pandas, which returns the first n rows.#### Approach
1. Use the `head(3)` method on the DataFrame to get the first three rows.2. Return or display the resulting DataFrame.#### Code
#### Complexity
-โฐ Time complexity:`O(1)`, as only the first three rows are accessed.-๐งบ Space complexity:`O(1)`, as no extra space is used beyond the output.