11from distutils .version import LooseVersion
2- import sys
2+ from functools import reduce
3+ from io import StringIO
4+ from urllib .error import HTTPError
35
46import pandas as pd
57from pandas .api .types import is_list_like , is_number
68import pandas .io .common as com
79from pandas .util .testing import assert_frame_equal
810
9- PY3 = sys .version_info >= (3 , 0 )
10-
1111PANDAS_VERSION = LooseVersion (pd .__version__ )
1212
1313PANDAS_0210 = PANDAS_VERSION >= LooseVersion ("0.21.0" )
3030 "lmap" ,
3131 "lrange" ,
3232 "concat" ,
33+ "reduce" ,
3334]
3435
3536
@@ -45,34 +46,16 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None):
4546 )
4647
4748
48- if PY3 :
49- from urllib .error import HTTPError
50- from functools import reduce
51-
52- string_types = (str ,)
53- binary_type = bytes
54- from io import StringIO
55-
56- def str_to_bytes (s , encoding = None ):
57- return s .encode (encoding or "ascii" )
58-
59- def bytes_to_str (b , encoding = None ):
60- return b .decode (encoding or "utf-8" )
61-
49+ string_types = (str ,)
50+ binary_type = bytes
6251
63- else :
64- from urllib2 import HTTPError
65- from cStringIO import StringIO
6652
67- reduce = reduce
68- binary_type = str
69- string_types = (basestring ,) # noqa: F821
53+ def str_to_bytes (s , encoding = None ):
54+ return s .encode (encoding or "ascii" )
7055
71- def bytes_to_str (b , encoding = None ):
72- return b
7356
74- def str_to_bytes ( s , encoding = None ):
75- return s
57+ def bytes_to_str ( b , encoding = None ):
58+ return b . decode ( encoding or "utf-8" )
7659
7760
7861def lmap (* args , ** kwargs ):
0 commit comments