1
1
from distutils .version import LooseVersion
2
- import sys
2
+ from functools import reduce
3
+ from io import StringIO
4
+ from urllib .error import HTTPError
3
5
4
6
import pandas as pd
5
7
from pandas .api .types import is_list_like , is_number
6
8
import pandas .io .common as com
7
9
from pandas .util .testing import assert_frame_equal
8
10
9
- PY3 = sys .version_info >= (3 , 0 )
10
-
11
11
PANDAS_VERSION = LooseVersion (pd .__version__ )
12
12
13
13
PANDAS_0210 = PANDAS_VERSION >= LooseVersion ("0.21.0" )
30
30
"lmap" ,
31
31
"lrange" ,
32
32
"concat" ,
33
+ "reduce" ,
33
34
]
34
35
35
36
@@ -45,34 +46,16 @@ def get_filepath_or_buffer(filepath_or_buffer, encoding=None, compression=None):
45
46
)
46
47
47
48
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
62
51
63
- else :
64
- from urllib2 import HTTPError
65
- from cStringIO import StringIO
66
52
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" )
70
55
71
- def bytes_to_str (b , encoding = None ):
72
- return b
73
56
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" )
76
59
77
60
78
61
def lmap (* args , ** kwargs ):
0 commit comments