Imagine that I have a single Dataframe as such:
df = pd.DataFrame([[1,2,3,None],[1,2,3,None],[1,2,3,None],[None,2,3,1]], columns=["A","B","C","AA"])
| A | B | C | AA |
|---|---|---|---|
| 1 | 2 | 3 | |
| 1 | 2 | 3 | |
| 2 | 3 | 1 |
Column AA is actually the same as A, but has suffered a typo somewhere in the data processing pipeline precious steps.
How can I actually rename ['AA'] to ['A'] and move the non-missing values? Example:
| A | B | C |
|---|---|---|
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
I imagine that if I do:
df['A'] = df['AA']
Null values will be copied.
So, any hints here?