Skip to content

Commit 4a27e63

Browse files
Merge pull request #7578 from clham/6838_set_option_doc
DOC: closes gh6838. Breakout options.rst from basics.rst
2 parents 4c5ac6a + 39e8eed commit 4a27e63

File tree

4 files changed

+411
-187
lines changed

4 files changed

+411
-187
lines changed

doc/source/basics.rst

-149
Original file line numberDiff line numberDiff line change
@@ -1552,152 +1552,3 @@ While float dtypes are unchanged.
15521552
casted = dfa[df2>0]
15531553
casted
15541554
casted.dtypes
1555-
1556-
1557-
Working with package options
1558-
----------------------------
1559-
1560-
.. _basics.working_with_options:
1561-
.. versionadded:: 0.10.1
1562-
1563-
pandas has an options system that let's you customize some aspects of it's behaviour,
1564-
display-related options being those the user is must likely to adjust.
1565-
1566-
Options have a full "dotted-style", case-insensitive name (e.g. ``display.max_rows``),
1567-
You can get/set options directly as attributes of the top-level ``options`` attribute:
1568-
1569-
.. ipython:: python
1570-
1571-
import pandas as pd
1572-
pd.options.display.max_rows
1573-
pd.options.display.max_rows = 999
1574-
pd.options.display.max_rows
1575-
1576-
1577-
There is also an API composed of 4 relevant functions, available directly from the ``pandas``
1578-
namespace, and they are:
1579-
1580-
- ``get_option`` / ``set_option`` - get/set the value of a single option.
1581-
- ``reset_option`` - reset one or more options to their default value.
1582-
- ``describe_option`` - print the descriptions of one or more options.
1583-
1584-
**Note:** developers can check out pandas/core/config.py for more info.
1585-
1586-
All of the functions above accept a regexp pattern (``re.search`` style) as an argument,
1587-
and so passing in a substring will work - as long as it is unambiguous :
1588-
1589-
.. ipython:: python
1590-
1591-
get_option("display.max_rows")
1592-
set_option("display.max_rows",101)
1593-
get_option("display.max_rows")
1594-
set_option("max_r",102)
1595-
get_option("display.max_rows")
1596-
1597-
1598-
The following will **not work** because it matches multiple option names, e.g. ``display.max_colwidth``, ``display.max_rows``, ``display.max_columns``:
1599-
1600-
.. ipython:: python
1601-
:okexcept:
1602-
1603-
try:
1604-
get_option("display.max_")
1605-
except KeyError as e:
1606-
print(e)
1607-
1608-
1609-
**Note:** Using this form of shorthand may cause your code to break if new options with similar names are added in future versions.
1610-
1611-
1612-
You can get a list of available options and their descriptions with ``describe_option``. When called
1613-
with no argument ``describe_option`` will print out the descriptions for all available options.
1614-
1615-
.. ipython:: python
1616-
:suppress:
1617-
1618-
reset_option("all")
1619-
1620-
1621-
.. ipython:: python
1622-
1623-
describe_option()
1624-
1625-
1626-
or you can get the description for just the options that match the regexp you pass in:
1627-
1628-
.. ipython:: python
1629-
1630-
describe_option("date")
1631-
1632-
1633-
All options also have a default value, and you can use the ``reset_option`` to do just that:
1634-
1635-
.. ipython:: python
1636-
:suppress:
1637-
1638-
reset_option("display.max_rows")
1639-
1640-
1641-
.. ipython:: python
1642-
1643-
get_option("display.max_rows")
1644-
set_option("display.max_rows",999)
1645-
get_option("display.max_rows")
1646-
reset_option("display.max_rows")
1647-
get_option("display.max_rows")
1648-
1649-
1650-
It's also possible to reset multiple options at once (using a regex):
1651-
1652-
.. ipython:: python
1653-
1654-
reset_option("^display")
1655-
1656-
1657-
.. versionadded:: 0.13.1
1658-
1659-
Beginning with v0.13.1 the `option_context` context manager has been exposed through
1660-
the top-level API, allowing you to execute code with given option values. Option values
1661-
are restored automatically when you exit the `with` block:
1662-
1663-
.. ipython:: python
1664-
1665-
with option_context("display.max_rows",10,"display.max_columns", 5):
1666-
print get_option("display.max_rows")
1667-
print get_option("display.max_columns")
1668-
1669-
print get_option("display.max_rows")
1670-
print get_option("display.max_columns")
1671-
1672-
1673-
Console Output Formatting
1674-
-------------------------
1675-
1676-
.. _basics.console_output:
1677-
1678-
Use the ``set_eng_float_format`` function in the ``pandas.core.common`` module
1679-
to alter the floating-point formatting of pandas objects to produce a particular
1680-
format.
1681-
1682-
For instance:
1683-
1684-
.. ipython:: python
1685-
1686-
set_eng_float_format(accuracy=3, use_eng_prefix=True)
1687-
s = Series(randn(5), index=['a', 'b', 'c', 'd', 'e'])
1688-
s/1.e3
1689-
s/1.e6
1690-
1691-
.. ipython:: python
1692-
:suppress:
1693-
1694-
reset_option('^display\.')
1695-
1696-
1697-
The ``set_printoptions`` function has a number of options for controlling how
1698-
floating point numbers are formatted (using the ``precision`` argument) in the
1699-
console and . The ``max_rows`` and ``max_columns`` control how many rows and
1700-
columns of DataFrame objects are shown by default. If ``max_columns`` is set to
1701-
0 (the default, in fact), the library will attempt to fit the DataFrame's
1702-
string representation into the current terminal width, and defaulting to the
1703-
summary view otherwise.

doc/source/faq.rst

-38
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,6 @@ Frequently Asked Questions (FAQ)
2424
options.display.mpl_style='default'
2525
from pandas.compat import lrange
2626
27-
28-
.. _ref-repr-control:
29-
30-
How do I control the way my DataFrame is displayed?
31-
---------------------------------------------------
32-
33-
pandas users rely on a variety of environments for using pandas: scripts, terminal,
34-
IPython qtconsole/ notebook, (IDLE, spyder, etc').
35-
Each environment has it's own capabilities and limitations: HTML support,
36-
horizontal scrolling, auto-detection of width/height.
37-
To appropriately address all these environments, the display behavior is controlled
38-
by several options, which you're encouraged to tweak to suit your setup.
39-
40-
As of 0.13, these are the relevant options, all under the `display` namespace,
41-
(e.g. ``display.width``, etc.):
42-
43-
- notebook_repr_html: if True, IPython frontends with HTML support will display
44-
dataframes as HTML tables when possible.
45-
- large_repr (default 'truncate'): when a :class:`~pandas.DataFrame`
46-
exceeds max_columns or max_rows, it can be displayed either as a
47-
truncated table or, with this set to 'info', as a short summary view.
48-
- max_columns (default 20): max dataframe columns to display.
49-
- max_rows (default 60): max dataframe rows display.
50-
- show_dimensions (default True): controls the display of the row/col counts footer.
51-
52-
Two additional options only apply to displaying DataFrames in terminals,
53-
not to the HTML view:
54-
55-
- expand_repr (default True): when the frame width cannot fit within
56-
the screen, the output will be broken into multiple pages.
57-
- width: width of display screen in characters, used to determine the
58-
width of lines when expand_repr is active. Setting this to None will
59-
trigger auto-detection of terminal width.
60-
61-
IPython users can use the IPython startup file to import pandas and set these
62-
options automatically when starting up.
63-
64-
6527
.. _ref-monkey-patching:
6628

6729
Adding Features to your pandas Installation

doc/source/index.rst.template

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ See the package overview for more detail about what's in the library.
122122
cookbook
123123
dsintro
124124
basics
125+
options
125126
indexing
126127
computation
127128
missing_data

0 commit comments

Comments
 (0)