Search⌘ K
AI Features

Exercise: Sorting, Columns, Filtering, and Indexing Operations.

Explore techniques for sorting by index or columns, filtering rows and columns by position and name, and indexing DataFrames efficiently. This lesson helps you gain hands-on experience manipulating pandas DataFrames for effective data analysis.

Problem 1: Sorting

Given the following DataFrame:

col1 col2 col3 col4
0 A B C D
1 E F NaN H
2 I J Z Y
3 S X E V
4 Q A B W

Perform the following operations:

a) Sort the index.

b) Sort by a single column col1.

c) Sort by col1 in ...