In [1]:
'''
Read data from a file that looks like this:
2013-03-26 08:51:18 69.35 20.75
2013-03-26 08:56:19 69.35 20.75
2013-03-26 09:01:19 69.125 20.625
2013-03-26 09:06:20 69.6866 20.937
'''
Out[1]:
In [2]:
import pandas as pd
log_file = './data/temperaturedata2013-03-25-22-19-23.log'
df = pd.read_csv(log_file, parse_dates =[[0,1]],header=None,index_col=0,
sep=r"\s*",names=['date','time','F','C'])
df.plot();ylabel('temp')
Out[2]:
In [7]:
df_15 = df.resample('15min',how='mean')
df_15.plot();ylabel('temp')
Out[7]:
In [4]:
df.head(10)
Out[4]:
In [ ]:
In [3]:
import numpy as np
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
In [17]:
data=np.genfromtxt(log_file,dtype=None,names=['date','time','F','C'])
In [20]:
dates=mdates.datestr2num(data['date']) # get the integer day
times,null=np.modf(mdates.datestr2num(data['time'])) # get fractional day
In [22]:
jd=dates+times # add fractional day to integer day
In [38]:
fig=plt.figure(figsize=(10,5))
ax1 = fig.add_subplot(111)
ax1.plot_date(jd,data['C'],'ko-');
plt.grid()
plt.ylabel('Temp')
Out[38]:
In [ ]: