Conteúdo do Curso
Pandas First Steps
Pandas First Steps
Viewing the Data
To view the first few rows of a dataset, we can utilize the head()
method. This method accepts an integer as its argument, which specifies the number of rows to display (by default, it shows first 5 rows). Let's take a look at the first 10 rows of our dataset:
If we want to see the last few rows of a DataFrame, we can use the tail()
method. It works similarly to the head()
method:
Another useful method for exploring DataFrames is sample()
. This method fetches random records from a DataFrame. By default, it retrieves a single random record unless specified otherwise.
Swipe to show code editor
You have a dataframe named wine_data
.
- Extract the first 10 rows from this DataFrame.
- Retrieve the last 15 rows from this DataFrame.
- Select a random sample of 12 rows from this DataFrame.
Solução
Obrigado pelo seu feedback!
Viewing the Data
To view the first few rows of a dataset, we can utilize the head()
method. This method accepts an integer as its argument, which specifies the number of rows to display (by default, it shows first 5 rows). Let's take a look at the first 10 rows of our dataset:
If we want to see the last few rows of a DataFrame, we can use the tail()
method. It works similarly to the head()
method:
Another useful method for exploring DataFrames is sample()
. This method fetches random records from a DataFrame. By default, it retrieves a single random record unless specified otherwise.
Swipe to show code editor
You have a dataframe named wine_data
.
- Extract the first 10 rows from this DataFrame.
- Retrieve the last 15 rows from this DataFrame.
- Select a random sample of 12 rows from this DataFrame.
Solução
Obrigado pelo seu feedback!