Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +---------------------+------+------+-----+-------+
- | date | open | high | low | close |
- +---------------------+------+------+-----+-------+
- | 2018-04-04 20:00:00 | xxx | xxx | xxx | xxx |
- | 2018-04-04 21:00:00 | xxx | xxx | xxx | xxx |
- | 2018-04-04 22:00:00 | xxx | xxx | xxx | xxx |
- +---------------------+------+------+-----+-------+
- +---------------------+------+------+-----+-------+
- | date | open | high | low | close |
- +---------------------+------+------+-----+-------+
- | 2018-04-04 20:00:00 | xxx | xxx | xxx | xxx |
- | 2018-04-04 21:00:00 | xxx | xxx | xxx | xxx |
- | 2018-04-04 22:00:00 | xxx | xxx | xxx | xxx |
- +---------------------+------+------+-----+-------+
- +---------------------+---------+------+-----+-------+
- | | | | | |
- +---------------------+---------+------+-----+-------+
- | 2018-04-04 20:00:00 | source1 | | | |
- | | open | high | low | close |
- | | xxx | xxx | xxx | xxx |
- | | source2 | | | |
- | | open | high | low | close |
- | | xxx | xxx | xxx | xxx |
- | 2018-04-04 21:00:00 | source1 | | | |
- | | open | high | low | close |
- | | xxx | xxx | xxx | xxx |
- | | source2 | | | |
- | | open | high | low | close |
- | | xxx | xxx | xxx | xxx |
- | 2018-04-04 22:00:00 | source1 | | | |
- | | open | high | low | close |
- | | xxx | xxx | xxx | xxx |
- | | source2 | | | |
- | | open | high | low | close |
- | | xxx | xxx | xxx | xxx |
- +---------------------+---------+------+-----+-------+
- df3 = pd.concat([df1,df2],keys=['source1','source2']).reset_index(level=0)
- df3 = df3.set_index(['date','level_0']).sort_index(level='date')
- open high low close
- date level_0
- 2018-04-04 20:00:00 source1 xxx xxx xxx xxx
- source2 xxx xxx xxx xxx
- 2018-04-04 21:00:00 source1 xxx xxx xxx xxx
- source2 xxx xxx xxx xxx
- 2018-04-04 22:00:00 source1 xxx xxx xxx xxx
- source2 xxx xxx xxx xxx
Add Comment
Please, Sign In to add comment