Using matplotlib/pandas/python, I cannot visualize data as values per 30mins and per days is a new question, which is strongly related to this question.
I want to visualize CSV data with Matplotlib.
Following is my code named 1.30mins.py
import matplotlib.pyplot as plt
from matplotlib import style
import numpy as np
style.use('ggplot')
x,y =np.loadtxt('total_watt.csv',
unpack = True,
delimiter = ',')
plt.plot(x,y)
plt.title('Example')
plt.ylabel('Y axis')
plt.xlabel('X axis')
plt.show()
When I implemtented 1.30mins.py
, I got a following error message.
(DataVizProj)Soma-Suzuki:Soma Suzuki$ python 1.30mins.py
Traceback (most recent call last):
File "1.30mins.py", line 10, in <module>
delimiter = ',')
File "/Users/Suzuki/Envs/DataVizProj/lib/python2.7/site-packages/numpy/lib/npyio.py", line 856, in loadtxt
items = [conv(val) for (conv, val) in zip(converters, vals)]
ValueError: invalid literal for float(): 2011-04-18 13:22:00
This is my total_watt.csv
2011-04-18 21:22:00 659.670303375527
2011-04-18 21:52:00 576.304871428571
2011-04-18 22:22:00 2,497.20620579196
2011-04-18 22:52:00 2,790.20392088608
2011-04-18 23:22:00 1,092.20906629318
2011-04-18 23:52:00 825.994417375886
2011-04-19 00:22:00 2,397.16672089666
2011-04-19 00:52:00 1,411.66659265233
As far as I searched by myself, I need to add converters
or, %y-%m-%t
to my program.
My python version is 2.76 My matpltlib version is 1.42