How To Combine Data Frames With Different (but Sometimes Overlapping) Indexes Over A Period Of Time In Pandas?
This is a continuation of my other StackOverflow post. Suppose I have a few data frames that are coming in with any random order (below, I'll mock those data frames). # assume tha
Solution 1:
concat
+ groupby
on axis=1
l=[df1,df2,df3,df4]
m=pd.concat(l,axis=1,sort=False)
m.groupby(m.columns,axis=1).first().fillna('') #ideally don't use the fillna
2016-01 2016-02 2016-03 2016-04 2017-01 2017-02 2017-03 2017-04
N1 A1 B1 C1 D1 A1 B1 C1 D1
N2 A2 B2 C2 D2 A2 B2 C2 D2
N3 A3 B3 C3 D3 A3 B3 C3 D3
N4 A4 B4 C4 D4
N5 A5 B5 C5 D5
N6 A6 B6 C6 D6 A6 B6 C6 D6
N7 A7 B7 C7 D7 A7 B7 C7 D7
N8 A8 B8 C8 D8
N9 A9 B9 C9 D9 A9 B9 C9 D9
N10 A10 B10 C10 D10
Post a Comment for "How To Combine Data Frames With Different (but Sometimes Overlapping) Indexes Over A Period Of Time In Pandas?"