-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Load_converter: TypeError: strptime() argument 0 must be str, not <class 'bytes'> #4126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Which version of matplotlib are you using? Which version of python are you On Wed, Feb 18, 2015 at 3:49 PM, keigolee514 [email protected]
|
Matplotlib: 1.8.2 Thank you! |
1.8.2? Are you a time traveler? On Wed, Feb 18, 2015 at 4:05 PM, keigolee514 [email protected]
|
sorry, 1.4.2... |
The problem is that numpy passes a byte string to the converter instead of a string. In python 2, since We could add another converter for byte input to the @keigolee514, you could use the following to get it working for you: from __future__ import print_function
from matplotlib.dates import strpdate2num
#from matplotlib.mlab import load
import numpy as np
from pylab import figure, show
import matplotlib.cbook as cbook
def bytespdate2num(fmt, encoding='utf-8'):
strconverter = strpdate2num(fmt)
def bytesconverter(b):
s = b.decode(encoding)
return strconverter(s)
return bytesconverter
datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print('loading', datafile)
dates, closes = np.loadtxt(
datafile, delimiter=',',
converters={0:bytespdate2num('%d-%b-%y')},
skiprows=1, usecols=(0,2), unpack=True)
fig = figure()
ax = fig.add_subplot(111)
ax.plot_date(dates, closes, '-')
fig.autofmt_xdate()
show() |
Closed by #4153 |
* Update of README.md * printing python3-compatibly * colors adjusted * 20160521T0928 * 20160521T1258 * prevent destructive lftp * readibility * python3 ready * attempt at preventing lftp from breaking the website * fail exit always * Try out for python3.4 compatibility * Revert "Try out for python3.4 compatibility" This reverts commit 851acbd. * `chmod 744` * Migration to Python 3.4 * one `b` too many. PID file should not be opened in byte-mode. * Changed `python3.4` to `python3` because on Ubuntu Xenial (16.10.1) the shortcut to `python3.4` nolonger exists :-( * Make execution of gnuplot script version conditional * no transparency * Exception handling updated. Gotta catch em all * set timeout on lftp command * catch timeout and process the exception. log a critical error for now. * pass * complete list of required packages * system info on status page * import platform * chmod * add windroos * chmod 644 graphs * python3 * retrieve wind data * webpage update ad windgraph * graphing wind data * fix ref: matplotlib/matplotlib#4126 * make graph29 * use correct unit * plot direction on top of speed for better visibility * de-erroring pylama
import numpy as np date,open,close=np.loadtxt('000001.csv',delimiter=',',converters={0:mdates.strpdate2num('%m/%d/%Y')},skiprows=1,usecols=(0,1,4),unpack=True) plt,plot(date,open) for the same problem. ask for help |
@haunledeshuchang This sort of question is best handled on the mailing list ([email protected] you will need to join the list to post un-moderated. We try to keep the issues for bug reports or feature requests. |
seems I have same issue as @haunledeshuchang |
Bdw How does the function bytesconverter(b): gets called in, def bytespdate2num(fmt, encoding='utf-8'): |
The text was updated successfully, but these errors were encountered: