daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 2014-07-10 11:49:14.377102    45
  2. 2014-07-10 11:50:14.449150    45
  3. 2014-07-10 11:51:14.521168    21
  4. 2014-07-10 11:52:14.574241     8
  5. 2014-07-10 11:53:14.646137    11
  6. 2014-07-10 11:54:14.717688    14
  7.    
  8. #! /usr/bin/env python
  9. import pandas as pd
  10. import matplotlib.pyplot as plt
  11. data = pd.read_fwf('myfile.log',header=None,names=['time','amount'],widths=[27,5])
  12. data.time = pd.to_datetime(data['time'], format='%Y-%m-%d %H:%M:%S.%f')
  13. plt.plot(data.time,data.amount)
  14. plt.show()
  15.    
  16. data.time = pd.to_datetime(data['time'], format='%Y-%m-%d %H:%M:%S.%f')
  17. data.set_index('time') # Fails!!
  18. data.time.plot()
  19.    
  20. TypeError: Empty 'Series': no numeric data to plot
  21.    
  22. #! /usr/bin/env python
  23. import pandas as pd
  24. import matplotlib.pyplot as plt
  25. data = pd.read_fwf('myfile.log',header=None,names=['time','amount'],widths=[27,5])
  26. data.time = pd.to_datetime(data['time'], format='%Y-%m-%d %H:%M:%S.%f')
  27. data.set_index(['time'],inplace=True)
  28. data.plot()
  29.  
  30. #OR
  31. plt.plot(data.index, data.amount)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top