We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 96a5274 commit ba0e377Copy full SHA for ba0e377
pandas/compat/__init__.py
@@ -257,6 +257,16 @@ def u(s):
257
def u_safe(s):
258
return s
259
260
+ def to_str(s):
261
+ """
262
+ Convert bytes and non-string into Python 3 str
263
264
+ if isinstance(s, binary_type):
265
+ s = bytes_to_str(s)
266
+ elif not isinstance(s, string_types):
267
+ s = str(s)
268
+ return s
269
+
270
def strlen(data, encoding=None):
271
# encoding is for compat with PY2
272
return len(data)
@@ -302,6 +312,14 @@ def u_safe(s):
302
312
except:
303
313
304
314
315
316
317
+ Convert unicode and non-string into Python 2 str
318
319
+ if not isinstance(s, string_types):
320
321
322
305
323
306
324
try:
307
325
data = data.decode(encoding)
0 commit comments