@@ -135,9 +135,7 @@ def to_string(self):
135
135
if footer :
136
136
result .append (footer )
137
137
138
- if py3compat .PY3 :
139
- return unicode (u'\n ' .join (result ))
140
- return com .console_encode (u'\n ' .join (result ))
138
+ return unicode (u'\n ' .join (result ))
141
139
142
140
if py3compat .PY3 : # pragma: no cover
143
141
_encode_diff = lambda x : 0
@@ -200,10 +198,15 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
200
198
else :
201
199
self .columns = frame .columns
202
200
203
- def _to_str_columns (self , force_unicode = False ):
201
+ def _to_str_columns (self , force_unicode = None ):
204
202
"""
205
203
Render a DataFrame to a list of columns (as lists of strings).
206
204
"""
205
+ import warnings
206
+ if force_unicode is not None : # pragma: no cover
207
+ warnings .warn ("force_unicode is deprecated, it will have no effect" ,
208
+ FutureWarning )
209
+
207
210
# may include levels names also
208
211
str_index = self ._get_formatted_index ()
209
212
str_columns = self ._get_formatted_column_labels ()
@@ -237,32 +240,17 @@ def _to_str_columns(self, force_unicode=False):
237
240
if self .index :
238
241
strcols .insert (0 , str_index )
239
242
240
- if not py3compat .PY3 :
241
- if force_unicode :
242
- def make_unicode (x ):
243
- if isinstance (x , unicode ):
244
- return x
245
- return x .decode ('utf-8' )
246
- strcols = map (lambda col : map (make_unicode , col ), strcols )
247
- else :
248
- # Generally everything is plain strings, which has ascii
249
- # encoding. Problem is when there is a char with value over
250
- # 127. Everything then gets converted to unicode.
251
- try :
252
- map (lambda col : map (str , col ), strcols )
253
- except UnicodeError :
254
- def make_unicode (x ):
255
- if isinstance (x , unicode ):
256
- return x
257
- return x .decode ('utf-8' )
258
- strcols = map (lambda col : map (make_unicode , col ), strcols )
259
-
260
243
return strcols
261
244
262
- def to_string (self , force_unicode = False ):
245
+ def to_string (self , force_unicode = None ):
263
246
"""
264
247
Render a DataFrame to a console-friendly tabular output.
265
248
"""
249
+ import warnings
250
+ if force_unicode is not None : # pragma: no cover
251
+ warnings .warn ("force_unicode is deprecated, it will have no effect" ,
252
+ FutureWarning )
253
+
266
254
frame = self .frame
267
255
268
256
if len (frame .columns ) == 0 or len (frame .index ) == 0 :
@@ -272,15 +260,20 @@ def to_string(self, force_unicode=False):
272
260
com .pprint_thing (frame .index )))
273
261
text = info_line
274
262
else :
275
- strcols = self ._to_str_columns (force_unicode )
263
+ strcols = self ._to_str_columns ()
276
264
text = adjoin (1 , * strcols )
277
265
278
266
self .buf .writelines (text )
279
267
280
- def to_latex (self , force_unicode = False , column_format = None ):
268
+ def to_latex (self , force_unicode = None , column_format = None ):
281
269
"""
282
270
Render a DataFrame to a LaTeX tabular environment output.
283
271
"""
272
+ import warnings
273
+ if force_unicode is not None : # pragma: no cover
274
+ warnings .warn ("force_unicode is deprecated, it will have no effect" ,
275
+ FutureWarning )
276
+
284
277
frame = self .frame
285
278
286
279
if len (frame .columns ) == 0 or len (frame .index ) == 0 :
@@ -289,7 +282,7 @@ def to_latex(self, force_unicode=False, column_format=None):
289
282
frame .columns , frame .index ))
290
283
strcols = [[info_line ]]
291
284
else :
292
- strcols = self ._to_str_columns (force_unicode )
285
+ strcols = self ._to_str_columns ()
293
286
294
287
if column_format is None :
295
288
column_format = '|l|%s|' % '|' .join ('c' for _ in strcols )
0 commit comments