Computer scienceData scienceInstrumentsPandasData preprocessing with pandas

Sorting Data in Pandas

Dwelling shuffle

Report a typo

Sort the following dataset df by the index column in ascending order and print the result.

+----+--------------------+------------------+---------------------+
|    | type_of_dwelling   | walls_material   |   number_of_persons |
|----+--------------------+------------------+---------------------|
| 41 | Private house      | wood             |                   4 |
| 44 | Townhouse          | concrete         |                   8 |
| 42 | Apartment          | blocks           |                   2 |
| 43 | Townhouse          | bricks           |                   3 |
+----+--------------------+------------------+---------------------+
Write a program in Python 3
import pandas as pd

df = pd.DataFrame({
"type_of_dwelling": ['Private house', 'Townhouse', 'Apartment', 'Townhouse'],
"walls_material": ['wood', 'concrete', 'blocks', 'bricks'],
"number_of_persons": [4, 8, 2, 3]},
index=[41, 44, 42, 43])

# your code here
print(...)
___

Create a free account to access the full topic