Computer scienceData scienceInstrumentsPandasData preprocessing with pandas

Sorting Data in Pandas

TTT

Report a typo

Look at the following DataFrame:

+------+--------+--------+-------+
|      | tick   | tack   | toe   |
|------+--------+--------+-------|
| tick | X      | O      | O     |
| tack | O      | O      | X     |
| toe  | O      | X      | O     |
+------+--------+--------+-------+

Change the column and row order by sorting them alphabetically, so that the 'X' would win!

Then print the resulting DataFrame.

Tip: Use reindex() and sort_index() in any order. Just chain them - write one after another. [\HINT]

Write a program in Python 3
import pandas as pd

t_t_t = pd.DataFrame({
"tick": ["X", "O", 'O'],
"tack": ["O", "O", 'X'],
"toe": ["O", "X", 'O'],
}, index=['tick', 'tack', 'toe'])

# your code here
print(...)
___

Create a free account to access the full topic