Guest User

Untitled

a guest
May 23rd, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. +---------------------+------+------+-----+-------+
  2. | date | open | high | low | close |
  3. +---------------------+------+------+-----+-------+
  4. | 2018-04-04 20:00:00 | xxx | xxx | xxx | xxx |
  5. | 2018-04-04 21:00:00 | xxx | xxx | xxx | xxx |
  6. | 2018-04-04 22:00:00 | xxx | xxx | xxx | xxx |
  7. +---------------------+------+------+-----+-------+
  8.  
  9. +---------------------+------+------+-----+-------+
  10. | date | open | high | low | close |
  11. +---------------------+------+------+-----+-------+
  12. | 2018-04-04 20:00:00 | xxx | xxx | xxx | xxx |
  13. | 2018-04-04 21:00:00 | xxx | xxx | xxx | xxx |
  14. | 2018-04-04 22:00:00 | xxx | xxx | xxx | xxx |
  15. +---------------------+------+------+-----+-------+
  16.  
  17. +---------------------+---------+------+-----+-------+
  18. | | | | | |
  19. +---------------------+---------+------+-----+-------+
  20. | 2018-04-04 20:00:00 | source1 | | | |
  21. | | open | high | low | close |
  22. | | xxx | xxx | xxx | xxx |
  23. | | source2 | | | |
  24. | | open | high | low | close |
  25. | | xxx | xxx | xxx | xxx |
  26. | 2018-04-04 21:00:00 | source1 | | | |
  27. | | open | high | low | close |
  28. | | xxx | xxx | xxx | xxx |
  29. | | source2 | | | |
  30. | | open | high | low | close |
  31. | | xxx | xxx | xxx | xxx |
  32. | 2018-04-04 22:00:00 | source1 | | | |
  33. | | open | high | low | close |
  34. | | xxx | xxx | xxx | xxx |
  35. | | source2 | | | |
  36. | | open | high | low | close |
  37. | | xxx | xxx | xxx | xxx |
  38. +---------------------+---------+------+-----+-------+
  39.  
  40. df3 = pd.concat([df1,df2],keys=['source1','source2']).reset_index(level=0)
  41.  
  42. df3 = df3.set_index(['date','level_0']).sort_index(level='date')
  43.  
  44.  
  45.  
  46. open high low close
  47. date level_0
  48. 2018-04-04 20:00:00 source1 xxx xxx xxx xxx
  49. source2 xxx xxx xxx xxx
  50. 2018-04-04 21:00:00 source1 xxx xxx xxx xxx
  51. source2 xxx xxx xxx xxx
  52. 2018-04-04 22:00:00 source1 xxx xxx xxx xxx
  53. source2 xxx xxx xxx xxx
Add Comment
Please, Sign In to add comment