我不能用这个来描绘我的生活

时间:2017-01-31 18:37:59

标签: python python-2.7 pandas

无数个小时盯着这个改变周围的一切,我疯了!我输了。我无法得到这些数据。我觉得我很亲密,但没有雪茄。我希望有一条线与时间。任何帮助将不胜感激。

import matplotlib.pyplot as plt
import pandas as pd #this is how I usually import pandas
import sys #only needed to determine Python version number
import matplotlib
import numpy as np 
import pylab as pl
import matplotlib.dates as md
import dateutil
#print('Python version ' + sys.version)
#print('Pandas version ' + pd.__version__)
#print('Matplotlib version ' + matplotlib.__version__)
pd.set_option('display.mpl_style', 'default') 
pd.set_option('display.line_width', 5000) 
pd.set_option('display.max_columns', 60) 
force = pd.read_csv(open('press.csv','rU'), encoding='utf-8',       engine='c', header=None)
force.columns =  ["presst", "units", "pressm", "units2", "date", "time", "nothin"]
#plt.subplots_adjust(bottom=0.2)
#plt.xticks( rotation= 80 )
#ax=plt.gca()
#xfmt = md.DateFormatter('%H:%M:%S')
#ax.xaxis.set_major_formatter(xfmt)
#plt.figure()
#for i in range(len('presst')):
#    plt.plot('time'[i], 'presst'[i])
#plt.show()
    print(force)
      presst    units1 pressm   units2      date      time     nothin
0     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:14     NaN
1     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:14     NaN
2     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
3     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
4     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
5     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
6     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
7     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
8     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
9     40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
10    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
11    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:15     NaN
12    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:16     NaN
13    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:16     NaN
14    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:16     NaN
15    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:16     NaN
16    40.0      lbf   100.0      lbf  30 Jan 2017  13:07:16     NaN
17    40.0      lbf   100.0      lbf  30 Jan 2017        13     NaN

1 个答案:

答案 0 :(得分:1)

这对我有用

force['datetime'] = pd.to_datetime(force['date'] + " " + force['time'])

force.set_index('datetime').presst.plot()

enter image description here