Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Sorting Data | Explore Dataset
Practice
Projects
Quizzes & Challenges
Quiz
Challenges
/
Introduction to Python for Data Analysis
Section 3. Chapitre 4
single

single

bookSorting Data

Glissez pour afficher le menu

We need sorting for ease of work.

We can sort our data in 2 ways: ascending sorting and descending sorting.

To perform the ascending sorting, use the following code:

DataFrame.sort_values(by = 'column_name', inplace = True)

If we want to perform descending, we have to turn off the ascending parameter.

DataFrame.sort_values(by = 'column_name', inplace = True, ascending = False)

If the parameter inplace is set to True (inplace = True), it will perform the operation inplace. Modify the original DataFrame itself. The return type is None.

Tâche

Swipe to start coding

Now we are going to practice sorting. We will sort 2 different DataFrame columns using ascending and descending sorting.

  1. Import the pandas using the pd alias.
  2. Perform an ascending sorting by the 'price' column.
  3. Perform a descending sorting by the 'user_id' column.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 4
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt