我正在尝试阅读CSV的类型文件。它总结了一个日期线。 像其他人一样教我这样编写代码,但这是错误的。 我不知道为什么。请帮帮我。
from matplotlib.dates import strpdate2num
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import os
dates=np.loadtxt('data.csv',delimiter=',',usecols=(1,),
converters={ 1:strpdate2num('%d-%m-%Y')})
和错误信息如下:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-24-e58dd0485173> in <module>()
1 dates=np.loadtxt('data.csv',delimiter=',',usecols=(1,),
----> 2 converters={ 1:strpdate2num('%d-%m-%Y')})
C:\Anaconda3\lib\site-packages\numpy\lib\npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin)
928
929 # Convert each value according to its column and store
--> 930 items = [conv(val) for (conv, val) in zip(converters, vals)]
931 # Then pack it according to the dtype's nesting
932 items = pack_items(items, packing)
C:\Anaconda3\lib\site-packages\numpy\lib\npyio.py in <listcomp>(.0)
928
929 # Convert each value according to its column and store
--> 930 items = [conv(val) for (conv, val) in zip(converters, vals)]
931 # Then pack it according to the dtype's nesting
932 items = pack_items(items, packing)
C:\Anaconda3\lib\site-packages\matplotlib\dates.py in __call__(self, s)
285 return value: a date2num float
286 """
--> 287 return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))
288
289
C:\Anaconda3\lib\_strptime.py in _strptime_time(data_string, format)
557 """Return a time struct based on the input string and the
558 format string."""
--> 559 tt = _strptime(data_string, format)[0]
560 return time.struct_time(tt[:time._STRUCT_TM_ITEMS])
561
C:\Anaconda3\lib\_strptime.py in _strptime(data_string, format)
327 if not isinstance(arg, str):
328 msg = "strptime() argument {} must be str, not {}"
--> 329 raise TypeError(msg.format(index, type(arg)))
330
331 global _TimeRE_cache, _regex_cache
TypeError: strptime() argument 0 must be str, not <class 'bytes'>
答案 0 :(得分:2)
试试这个:
var slug = $("input[name='slug']:checked").val();
$(document).on('change', 'input', function() {
if (slug == "the_lone_snitch") {
$(".button").addClass("disabled")
}
else{
//This will enable to button when radio button is not equal to "the_lone_snitch"
$(".button").removeClass("disabled")
}
});