Computer scienceData scienceInstrumentsPandasData analysis with pandas

Reshaping and Pivot Tables

Reshaping

Report a typo

Imagine you work with the following dataset df:

+----+----------+----------+-----------------+
|    | Letter   |   Number | Number&Letter   |
|----+----------+----------+-----------------|
|  0 | A        |        1 | A1              |
|  1 | B        |        1 | B1              |
|  2 | A        |        3 | A3              |
|  3 | B        |        2 | B2              |
|  4 | A        |        2 | A2              |
+----+----------+----------+-----------------+

You'd like to reshape the DataFrame to get something like this:

+----------+-----+-----+
|   Letter | A   | B   |
|   Number |     |     |
|----------+-----+-----|
|        1 | A1  | B1  |
|        2 | A2  | B2  |
|        3 | A3  | B3  |
+----------+-----+-----+

How could you do this?

Select one option from the list
___

Create a free account to access the full topic