11
11
"""
12
12
13
13
import pandas .core .config as cf
14
- from pandas .core .config import (is_int , is_bool , is_text , is_float ,
15
- is_instance_factory , is_one_of_factory ,
16
- get_default_val )
14
+ from pandas .core .config import (is_int , is_bool , is_text , is_instance_factory ,
15
+ is_one_of_factory , get_default_val )
17
16
from pandas .core .format import detect_console_encoding
18
17
19
-
20
18
#
21
19
# options from the "display" namespace
22
20
61
59
62
60
pc_max_categories_doc = """
63
61
: int
64
- This sets the maximum number of categories pandas should output when printing
65
- out a `Categorical` or a Series of dtype "category".
62
+ This sets the maximum number of categories pandas should output when
63
+ printing out a `Categorical` or a Series of dtype "category".
66
64
"""
67
65
68
66
pc_max_info_cols_doc = """
146
144
147
145
pc_east_asian_width_doc = """
148
146
: boolean
149
- Whether to use the Unicode East Asian Width to calculate the display text width
147
+ Whether to use the Unicode East Asian Width to calculate the display text
148
+ width.
150
149
Enabling this may affect to the performance (default: False)
151
150
"""
151
+
152
152
pc_ambiguous_as_wide_doc = """
153
153
: boolean
154
154
Whether to handle Unicode characters belong to Ambiguous as Wide (width=2)
197
197
: int or None
198
198
df.info() will usually show null-counts for each column.
199
199
For large frames this can be quite slow. max_info_rows and max_info_cols
200
- limit this null check only to frames with smaller dimensions then specified.
200
+ limit this null check only to frames with smaller dimensions than
201
+ specified.
201
202
"""
202
203
203
204
pc_large_repr_doc = """
222
223
223
224
pc_latex_escape = """
224
225
: bool
225
- This specifies if the to_latex method of a Dataframe uses escapes special
226
+ This specifies if the to_latex method of a Dataframe uses escapes special
226
227
characters.
227
- method. Valid values: False,True
228
+ method. Valid values: False,True
228
229
"""
229
230
230
231
pc_latex_longtable = """
231
232
:bool
232
- This specifies if the to_latex method of a Dataframe uses the longtable format.
233
- method. Valid values: False,True
233
+ This specifies if the to_latex method of a Dataframe uses the longtable
234
+ format.
235
+ method. Valid values: False,True
234
236
"""
235
237
236
238
style_backup = dict ()
@@ -244,7 +246,7 @@ def mpl_style_cb(key):
244
246
val = cf .get_option (key )
245
247
246
248
if 'matplotlib' not in sys .modules .keys ():
247
- if not ( val ) : # starting up, we get reset to None
249
+ if not val : # starting up, we get reset to None
248
250
return val
249
251
raise Exception ("matplotlib has not been imported. aborting" )
250
252
@@ -267,7 +269,8 @@ def mpl_style_cb(key):
267
269
validator = is_instance_factory ((int , type (None ))))
268
270
cf .register_option ('max_rows' , 60 , pc_max_rows_doc ,
269
271
validator = is_instance_factory ([type (None ), int ]))
270
- cf .register_option ('max_categories' , 8 , pc_max_categories_doc , validator = is_int )
272
+ cf .register_option ('max_categories' , 8 , pc_max_categories_doc ,
273
+ validator = is_int )
271
274
cf .register_option ('max_colwidth' , 50 , max_colwidth_doc , validator = is_int )
272
275
cf .register_option ('max_columns' , 20 , pc_max_cols_doc ,
273
276
validator = is_instance_factory ([type (None ), int ]))
@@ -305,28 +308,29 @@ def mpl_style_cb(key):
305
308
cf .register_option ('line_width' , get_default_val ('display.width' ),
306
309
pc_line_width_doc )
307
310
cf .register_option ('memory_usage' , True , pc_memory_usage_doc ,
308
- validator = is_one_of_factory ([None , True , False , 'deep' ]))
311
+ validator = is_one_of_factory ([None , True ,
312
+ False , 'deep' ]))
309
313
cf .register_option ('unicode.east_asian_width' , False ,
310
314
pc_east_asian_width_doc , validator = is_bool )
311
315
cf .register_option ('unicode.ambiguous_as_wide' , False ,
312
316
pc_east_asian_width_doc , validator = is_bool )
313
- cf .register_option ('latex.escape' ,True , pc_latex_escape ,
314
- validator = is_bool )
315
- cf .register_option ('latex.longtable' ,False ,pc_latex_longtable ,
316
- validator = is_bool )
317
+ cf .register_option ('latex.escape' , True , pc_latex_escape ,
318
+ validator = is_bool )
319
+ cf .register_option ('latex.longtable' , False , pc_latex_longtable ,
320
+ validator = is_bool )
317
321
318
322
cf .deprecate_option ('display.line_width' ,
319
323
msg = pc_line_width_deprecation_warning ,
320
324
rkey = 'display.width' )
321
325
322
- cf .deprecate_option ('display.height' ,
323
- msg = pc_height_deprecation_warning ,
326
+ cf .deprecate_option ('display.height' , msg = pc_height_deprecation_warning ,
324
327
rkey = 'display.max_rows' )
325
328
326
329
tc_sim_interactive_doc = """
327
330
: boolean
328
331
Whether to simulate interactive mode for purposes of testing
329
332
"""
333
+
330
334
with cf .config_prefix ('mode' ):
331
335
cf .register_option ('sim_interactive' , False , tc_sim_interactive_doc )
332
336
@@ -349,7 +353,6 @@ def use_inf_as_null_cb(key):
349
353
cf .register_option ('use_inf_as_null' , False , use_inf_as_null_doc ,
350
354
cb = use_inf_as_null_cb )
351
355
352
-
353
356
# user warnings
354
357
chained_assignment = """
355
358
: string
@@ -361,7 +364,6 @@ def use_inf_as_null_cb(key):
361
364
cf .register_option ('chained_assignment' , 'warn' , chained_assignment ,
362
365
validator = is_one_of_factory ([None , 'warn' , 'raise' ]))
363
366
364
-
365
367
# Set up the io.excel specific configuration.
366
368
writer_engine_doc = """
367
369
: string
@@ -371,8 +373,7 @@ def use_inf_as_null_cb(key):
371
373
372
374
with cf .config_prefix ('io.excel' ):
373
375
# going forward, will be additional writers
374
- for ext , options in [('xls' , ['xlwt' ]),
375
- ('xlsm' , ['openpyxl' ])]:
376
+ for ext , options in [('xls' , ['xlwt' ]), ('xlsm' , ['openpyxl' ])]:
376
377
default = options .pop (0 )
377
378
if options :
378
379
options = " " + ", " .join (options )
@@ -384,14 +385,13 @@ def use_inf_as_null_cb(key):
384
385
385
386
def _register_xlsx (engine , other ):
386
387
cf .register_option ('xlsx.writer' , engine ,
387
- writer_engine_doc .format (ext = 'xlsx' ,
388
- default = engine ,
388
+ writer_engine_doc .format (ext = 'xlsx' , default = engine ,
389
389
others = ", '%s'" % other ),
390
390
validator = str )
391
391
392
392
try :
393
393
# better memory footprint
394
- import xlsxwriter
394
+ import xlsxwriter # noqa
395
395
_register_xlsx ('xlsxwriter' , 'openpyxl' )
396
396
except ImportError :
397
397
# fallback
0 commit comments