-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC/PY3: Python 3 docs example compat for range, StringIO and datetime #6230
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
Conversation
seems ok to me...@y-p ? |
Is the conversion of |
as long as the Wherever the code does not explicitly require a sequence for random access e.g. foo[4], |
yep you can just use range (if u r iterating over it) use list(range) if you actually need a list |
Adapted. |
@@ -698,7 +698,7 @@ Experimental | |||
|
|||
nrows, ncols = 20000, 100 | |||
df1, df2, df3, df4 = [DataFrame(randn(nrows, ncols)) | |||
for _ in xrange(4)] | |||
for _ in list(range(4))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot this one I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing my nose into it... amended.
If this looks ok to you now, I could go ahead and squash... |
go ahead and squash |
done. |
@phaebz , please get rid of all the `list(range())`` where not required, I think that's |
@y-p regarding the PR, I think it is OK now. The remaining list in |
You're right, good. merging. |
DOC/PY3: Python 3 docs example compat for range, StringIO and datetime
related is #6212
Fixes examples in documentation to be compatible with Python 3. Also tested it locally under Python 2.
(x)range()
torange()
for iteration and tolist(range())
for list concat.datetime(2013, 01, 27)
.StringIO
andcStringIO
imports in examples (uses suppressed pandas.compat imports) and added a note on py2/3 library reorganization.StringIO
for binary data to the more explicitBytesIO
.NameError
for missingpd.
inpd.Series
.numpy.unique
example, see also DOC/PY3: np.unique errors on pd.Series with mixed string/float in python3 #6229.I am not sure about the
BytesIO
though. Maybe good to put a note saying this is Python 3 way to do it and users on 2.x should use the oldStringIO
instead. In general, should we favor Python 3 doc versions in such cases and add notes for Python 2.x users? What do you think?