I am trying to create a machine learning model and teaching myself as I go. I will be working with a large dataset, but before I get to that, I am practicing with a smaller dataset to make sure everything is working as expected. I will need to swap half of the rows of two columns in my dataset, and I am not sure how to accomplish this.
Say I have a dataframe like the below:
| index | number | letter |
|---|---|---|
| 0 | 1 | A |
| 1 | 2 | B |
| 2 | 3 | C |
| 3 | 4 | D |
| 4 | 5 | E |
| 5 | 6 | F |
I want to randomly swap half of the rows of the number and letter columns, so one output could look like this:
| index | number | letter |
|---|---|---|
| 0 | 1 | A |
| 1 | B | 2 |
| 2 | 3 | C |
| 3 | D | 4 |
| 4 | 5 | E |
| 5 | F | 6 |
Is there a way to do this in python?
edit: thank you for all of your answers, I greatly appreciate it! :)