我试图打开csv文件,然后将天数拉入days数组和时间数组中,但是我得到这个错误“AttributeError:'str'对象没有属性'day'”。我加入的图像什么的一个文件看起来像AttributeError:'str'对象在试图将日期和时间放到数组中时没有属性'day'错误
data = {'days': [],
'times': []}
with open(open_file) as in_f:
reader = DictReader(in_f)
for line in reader:
data['day'].append(line['time_received_isoformat'].day)
data['time'].append(line['time_received_isoformat'].hour * 60 + line['time_received_isoformat'].minute)
data = DataFrame(data)
plot = seaborn.stripplot(data=data, x='day', y='time')
plot.get_figure().savefig('/home/jacob/Projects/CIS2302/CW2/ddd_cw2/temporal_graphs/' + 'days_stripplot' + '.png')
pyplot.close()
line ['time_received_isoformat']似乎返回一个字符串不是一个dictionnay。尝试打印(行['time_received_isoformat']),看看它给你什么 –
Ino,但我不知道该怎么做才能解决它... – Jake123