You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/basics.rst
-149
Original file line number
Diff line number
Diff line change
@@ -1552,152 +1552,3 @@ While float dtypes are unchanged.
1552
1552
casted = dfa[df2>0]
1553
1553
casted
1554
1554
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
-
exceptKeyErroras 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
0 commit comments