Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ pandas 0.13
called using the top level matplotlib API (:issue:`4408`)
- Fixed a bug where calling ``Series.astype(str)`` would truncate the string
(:issue:`4405`, :issue:`4437`)
- Fixed a py3 compat issue where bytes were being repr'd as tuples
(:issue:`4455`)

pandas 0.12
===========
Expand Down
9 changes: 4 additions & 5 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,9 +1612,9 @@ def is_list_like(arg):
def _is_sequence(x):
try:
iter(x)
len(x) # it has a length
return not isinstance(x, compat.string_types) and True
except Exception:
len(x) # it has a length
return not isinstance(x, compat.string_types + (compat.binary_type,))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would define something like compat.string_and_binary_types

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw - that only matters for python3 - bytes is str in py2
On Aug 3, 2013 1:47 PM, "Phillip Cloud" [email protected] wrote:

In pandas/core/common.py:

@@ -1612,9 +1612,9 @@ def is_list_like(arg):
def _is_sequence(x):
try:
iter(x)

  •    len(x) # it has a length
    
  •    return not isinstance(x, compat.string_types) and True
    
  • except Exception:
  •    len(x)  # it has a length
    
  •    return not isinstance(x, compat.string_types + (compat.binary_type,))
    

ok


Reply to this email directly or view it on GitHubhttps://github.com//pull/4456/files#r5567493
.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but that's issue here...

except (TypeError, AttributeError):
return False

_ensure_float64 = algos.ensure_float64
Expand Down Expand Up @@ -2053,8 +2053,7 @@ def as_escaped_unicode(thing,escape_chars=escape_chars):

return compat.text_type(result)

if (compat.PY3 and hasattr(thing, '__next__')) or \
hasattr(thing, 'next'):
if (compat.PY3 and hasattr(thing, '__next__')) or hasattr(thing, 'next'):
return compat.text_type(thing)
elif (isinstance(thing, dict) and
_nest_lvl < get_option("display.pprint_nest_depth")):
Expand Down
19 changes: 17 additions & 2 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from datetime import datetime
import sys
import re

import nose
from nose.tools import assert_equal
import unittest

from pandas import Series, DataFrame, date_range, DatetimeIndex, Timestamp
from pandas.compat import range, long, lrange, lmap, u, map
from pandas.compat import range, long, lrange, lmap, u
from pandas.core.common import notnull, isnull
import pandas.core.common as com
import pandas.util.testing as tm
Expand Down Expand Up @@ -147,6 +147,21 @@ def test_all_not_none():
assert(not com._all_not_none(None, None, None, None))


def test_repr_binary_type():
import string
letters = string.ascii_letters
btype = compat.binary_type
try:
raw = btype(letters, encoding=cf.get_option('display.encoding'))
except TypeError:
raw = btype(letters)
b = compat.text_type(compat.bytes_to_str(raw))
res = com.pprint_thing(b, quote_strings=True)
assert_equal(res, repr(b))
res = com.pprint_thing(b, quote_strings=False)
assert_equal(res, b)


def test_rands():
r = com.rands(10)
assert(len(r) == 10)
Expand Down