Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 14th, 2013  |  syntax: None  |  size: 2.86 KB  |  views: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. atn   file
  2. datetime                            
  3. 2012-10-08 14:00:00  23.007462      1
  4. 2012-10-08 14:30:00  27.045666      1
  5. 2012-10-08 15:00:00  31.483825      1
  6. 2012-10-08 15:30:00  37.540651      2
  7. 2012-10-08 16:00:00  43.564573      2
  8. 2012-10-08 16:00:00  48.589852      2
  9. 2012-10-08 16:00:00  55.289452      2
  10.        
  11. datetime             atn
  12. file                            
  13. 1      2012-10-08 14:00:00  23.007462
  14. 2      2012-10-08 15:30:00  37.540651
  15.        
  16. dt.groupby(by="file").aggregate("first")
  17.        
  18. dt2 = dt.reset_index()
  19. dt2.groupby(by="file").aggregate("first")
  20.        
  21. datetime        atn
  22. file                        
  23. 1     1.349705e+18  23.007462
  24. 2     1.349710e+18  37.540651
  25.        
  26. 2012-10-08 14:00:00,  23.007462,     1
  27. 2012-10-08 14:30:00,  27.045666,     1
  28. 2012-10-08 15:00:00,  31.483825,     1
  29. 2012-10-08 15:30:00,  37.540651,     2
  30. 2012-10-08 16:00:00,  43.564573,     2
  31. 2012-10-08 16:00:00,  48.589852,     2
  32. 2012-10-08 16:00:00,  55.289452,     2
  33.        
  34. dt = pandas.read_clipboard(sep=",", parse_dates=True, index_col=0,
  35.                            names=["datetime", "atn", "file"])
  36.        
  37. dt3 = dt2.groupby(by="file").aggregate("first")
  38. dt3.dtypes
  39.        
  40. datetime    float64
  41. atn         float64
  42.        
  43. dt3['datetime'] = pd.Series(dt3['datetime'], dtype='datetime64[ns]')
  44.        
  45. In [29]: dt2 = pd.read_clipboard(sep=",", index_col=0,
  46.                            names=["datetime", "atn", "file"])
  47.  
  48. In [30]: dt2
  49. Out[30]:
  50.                            atn  file
  51. datetime                            
  52. 2012-10-08 14:00:00  23.007462     1
  53. 2012-10-08 14:30:00  27.045666     1
  54. 2012-10-08 15:00:00  31.483825     1
  55. 2012-10-08 15:30:00  37.540651     2
  56. 2012-10-08 16:00:00  43.564573     2
  57. 2012-10-08 16:00:00  48.589852     2
  58. 2012-10-08 16:00:00  55.289452     2
  59.  
  60. In [31]: dt2.reset_index().groupby(by="file").aggregate("first")
  61. Out[31]:
  62.                  datetime        atn
  63. file                                
  64. 1     2012-10-08 14:00:00  23.007462
  65. 2     2012-10-08 15:30:00  37.540651
  66.  
  67. In [32]:
  68.        
  69. In [33]: dt = pd.read_clipboard(sep=",", parse_dates=True, index_col=0,
  70.                            names=["datetime", "atn", "file"])
  71. KeyboardInterrupt
  72.  
  73. In [33]: dt = pd.read_clipboard(sep=",", parse_dates=True, index_col=0,
  74.                            names=["datetime", "atn", "file"])
  75.  
  76. In [34]: dt.reset_index().groupby(by="file").aggregate("first")
  77. Out[34]:
  78.           datetime        atn
  79. file                        
  80. 1     1.349705e+18  23.007462
  81. 2     1.349710e+18  37.540651
  82.        
  83. In [40]: new_dt = dt.reset_index().groupby(by="file").aggregate("first")
  84.  
  85. In [41]: new_dt
  86. Out[41]:
  87.           datetime        atn
  88. file                        
  89. 1     1.349705e+18  23.007462
  90. 2     1.349710e+18  37.540651
  91.  
  92. In [42]: new_dt.dtypes
  93. Out[42]:
  94. datetime    float64
  95. atn         float64
  96.  
  97. In [43]: new_dt2 = dt2.reset_index().groupby(by="file").aggregate("first")
  98.  
  99. In [44]: new_dt2.dtypes
  100. Out[44]:
  101. datetime     object
  102. atn         float64