无数小时盯着周围的一切发生变化,我快疯了!我迷路了。我无法绘制此数据。我觉得我很近,但没有雪茄。我希望有一条时间线。任何帮助,将不胜感激。
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
最佳答案
这对我有用
force['datetime'] = pd.to_datetime(force['date'] + " " + force['time'])
force.set_index('datetime').presst.plot()
关于python - 我不能一辈子都这样想,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41965080/