Bir csv'den tarihler çizmek istiyorum. diğer üç sütun sayısına göre sütun. Ben python için yeni ve şimdiye kadar sütunlar python içine almak için yönetilen var ve bunları okumak için denedim bir dizi var ama ben datetime modülü ile eklemek ve x eksen boyunca tarihler çizmek veri.Bir Tarihin csv'den çizilmesi. pylab dosyasındaki dosya
Lütfen herhangi bir kişi yardım edebilir mi? Ben hata mesajı almaya devam dakikada
:
Traceback (most recent call last):
File "H:\AppliedGIS\Python\woops.py", line 24, in <module>
date = datetime.datetime.strptime['x', '%d/%m/%Y']
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
Ama ben daha fazla yerde yanlış gidiyorum eminim ...
kendisi dört biçimlendirilmiş veri sütunlar ve basıldığı zaman: ('04/03/2013 ', 7.0, 12.0, 17.0) ('11/03/2013', 23.0, 15.0, 23.0).
Burada sorun datetime
aktardıktan şekilde olduğunu tam kod
import csv
import numpy as np
import pylab as pl
import datetime
from datetime import datetime
data = np.genfromtxt('H:/AppliedGIS/Python/AssignmentData/GrowthDistribution/full.csv', names=True, usecols=(0, 1, 2, 3), delimiter= ',', dtype =[('Date', 'S10'),('HIGH', '<f8'), ('Medium', '<f8'), ('Low', '<f8')])
print data
x = [foo['Date'] for foo in data]
y = [foo['HIGH'] for foo in data]
y2 = [foo['Medium'] for foo in data]
y3 = [foo['Low'] for foo in data]
print x, y, y2, y3
dates = []
for x in data:
date = datetime.datetime.strptime['x', '%d/%m/%Y']
dates.append(date)
pl.plot(data[:, x], data[:, y], '-r', label= 'High Stocking Rate')
pl.plot(data[:, x], data[:, y2], '-g', label= 'Medium Stocking Rate')
pl.plot(data[:, x], data[:, y3], '-b', label= 'Low Stocking Rate')
pl.title('Amount of Livestock Grazing per hectare', fontsize=18)
pl.ylabel('Livestock per ha')
pl.xlabel('Date')
pl.grid(True)
pl.ylim(0,100)
pl.show()
Etkileşimli bir Python oturumunda 'datetime' denediniz mi? – hpaulj