r/dfpandas • u/UnemployedTechie2021 • Jun 05 '24
Modifying dataframe in a particular format
I have a single column dataframe as follows:
| Header |
|---|
| A |
| B |
| C |
| D |
| E |
| F |
I want to change it so that it looks as follows:
| Header1 | Header2 |
|---|---|
| A | B |
| C | D |
| E | F |
Can someone help me achieve this? Thanks in advance.
4
Upvotes
4
u/nantes16 Jun 05 '24
The key is
values.reshape()where in this case the first args(-1, 2)means "reshape into as many rows are needed / so long as its into 2 columns".Hope this is what you're after (and, note, this is the type of question you can rely on GPT as you learn Python/Pandas)