I need to reformat some data. I've never used pandas before, and could use some help.
I have two DataFrames: df1 dfTarget
df1 is the un-formatted data, dfTarget is how I need the data to be formatted
Based on a condition, I need one group of columns in df1 to be copied to certain columns in dfTarget. If the condition is false, I need another group of columns in df1 to be copied to certain columns in dfTarget.
Simplified df1:
city state condition city2 state2
0
1
2
3
4
Simplified dfTarget:
mCity mState
0
1
2
3
4
Basically, if the condition is true, I need to move 'city' and 'state' into 'mCity' and 'mState' respectively. If the condition is false, I need to move 'city2' and 'state2' into 'mCity' and 'mState'.
dfTarget is starting off empty, and needs to be filled row by row based on a bunch of conditions in df1.
I've never used pandas, and tried to research this myself, but got lost quickly in all the different methods. Please, what's the best way to do this?