PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/pandas/core/config_init.py

https://github.com/thouis/pandas
Python | 173 lines | 156 code | 4 blank | 13 comment | 0 complexity | df4aa49bcf71ba05f4788e127e813900 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. import pandas.core.config as cf
  2. from pandas.core.config import is_int,is_bool,is_text,is_float
  3. from pandas.core.format import detect_console_encoding
  4. """
  5. This module is imported from the pandas package __init__.py file
  6. in order to ensure that the core.config options registered here will
  7. be available as soon as the user loads the package. if register_option
  8. is invoked inside specific modules, they will not be registered until that
  9. module is imported, which may or may not be a problem.
  10. If you need to make sure options are available even before a certain
  11. module is imported, register them here rather then in the module.
  12. """
  13. ###########################################
  14. # options from the "display" namespace
  15. pc_precision_doc="""
  16. : int
  17. Floating point output precision (number of significant digits). This is
  18. only a suggestion
  19. """
  20. pc_colspace_doc="""
  21. : int
  22. Default space for DataFrame columns, defaults to 12
  23. """
  24. pc_max_rows_doc="""
  25. : int
  26. This sets the maximum number of rows pandas should output when printing
  27. out various output. For example, this value determines whether the repr()
  28. for a dataframe prints out fully or just an summary repr.
  29. """
  30. pc_max_cols_doc="""
  31. : int
  32. max_rows and max_columns are used in __repr__() methods to decide if
  33. to_string() or info() is used to render an object to a string.
  34. Either one, or both can be set to 0 (experimental). Pandas will figure
  35. out how big the terminal is and will not display more rows or/and
  36. columns that can fit on it.
  37. """
  38. pc_max_info_cols_doc="""
  39. : int
  40. max_info_columns is used in DataFrame.info method to decide if
  41. per column information will be printed.
  42. """
  43. pc_nb_repr_h_doc="""
  44. : boolean
  45. When True (default), IPython notebook will use html representation for
  46. pandas objects (if it is available).
  47. """
  48. pc_date_dayfirst_doc="""
  49. : boolean
  50. When True, prints and parses dates with the day first, eg 20/01/2005
  51. """
  52. pc_date_yearfirst_doc="""
  53. : boolean
  54. When True, prints and parses dates with the year first, eg 2005/01/20
  55. """
  56. pc_pprint_nest_depth="""
  57. : int
  58. Defaults to 3.
  59. Controls the number of nested levels to process when pretty-printing
  60. """
  61. pc_multi_sparse_doc="""
  62. : boolean
  63. Default True, "sparsify" MultiIndex display (don't display repeated
  64. elements in outer levels within groups)
  65. """
  66. pc_encoding_doc="""
  67. : str/unicode
  68. Defaults to the detected encoding of the console.
  69. Specifies the encoding to be used for strings returned by to_string,
  70. these are generally strings meant to be displayed on the console.
  71. """
  72. float_format_doc="""
  73. : callable
  74. The callable should accept a floating point number and return
  75. a string with the desired format of the number. This is used
  76. in some places like SeriesFormatter.
  77. See core.format.EngFormatter for an example.
  78. """
  79. max_colwidth_doc="""
  80. : int
  81. The maximum width in characters of a column in the repr of
  82. a pandas data structure. When the column overflows, a "..."
  83. placeholder is embedded in the output.
  84. """
  85. colheader_justify_doc="""
  86. : 'left'/'right'
  87. Controls the justification of column headers. used by DataFrameFormatter.
  88. """
  89. pc_expand_repr_doc="""
  90. : boolean
  91. Default False
  92. Whether to print out the full DataFrame repr for wide DataFrames
  93. across multiple lines.
  94. If False, the summary representation is shown.
  95. """
  96. pc_line_width_doc="""
  97. : int
  98. Default 80
  99. When printing wide DataFrames, this is the width of each line.
  100. """
  101. with cf.config_prefix('display'):
  102. cf.register_option('precision', 7, pc_precision_doc, validator=is_int)
  103. cf.register_option('float_format', None, float_format_doc)
  104. cf.register_option('column_space', 12, validator=is_int)
  105. cf.register_option('max_rows', 100, pc_max_rows_doc, validator=is_int)
  106. cf.register_option('max_colwidth', 50, max_colwidth_doc, validator=is_int)
  107. cf.register_option('max_columns', 20, pc_max_cols_doc, validator=is_int)
  108. cf.register_option('max_info_columns', 100, pc_max_info_cols_doc,
  109. validator=is_int)
  110. cf.register_option('colheader_justify', 'right', colheader_justify_doc,
  111. validator=is_text)
  112. cf.register_option('notebook_repr_html', True, pc_nb_repr_h_doc,
  113. validator=is_bool)
  114. cf.register_option('date_dayfirst', False, pc_date_dayfirst_doc,
  115. validator=is_bool)
  116. cf.register_option('date_yearfirst', False, pc_date_yearfirst_doc,
  117. validator=is_bool)
  118. cf.register_option('pprint_nest_depth', 3, pc_pprint_nest_depth,
  119. validator=is_int)
  120. cf.register_option('multi_sparse', True, pc_multi_sparse_doc,
  121. validator=is_bool)
  122. cf.register_option('encoding', detect_console_encoding(), pc_encoding_doc,
  123. validator=is_text)
  124. cf.register_option('expand_frame_repr', True, pc_expand_repr_doc)
  125. cf.register_option('line_width', 80, pc_line_width_doc)
  126. tc_sim_interactive_doc="""
  127. : boolean
  128. Default False
  129. Whether to simulate interactive mode for purposes of testing
  130. """
  131. with cf.config_prefix('mode'):
  132. cf.register_option('sim_interactive', False, tc_sim_interactive_doc)
  133. use_inf_as_null_doc="""
  134. : boolean
  135. True means treat None, NaN, INF, -INF as null (old way),
  136. False means None and NaN are null, but INF, -INF are not null
  137. (new way).
  138. """
  139. # we don't want to start importing evrything at the global context level
  140. # or we'll hit circular deps.
  141. def use_inf_as_null_cb(key):
  142. from pandas.core.common import _use_inf_as_null
  143. _use_inf_as_null(key)
  144. with cf.config_prefix('mode'):
  145. cf.register_option('use_inf_as_null', False, use_inf_as_null_doc,
  146. cb=use_inf_as_null_cb)