Skip to content

Commit 20aba0f

Browse files
committed
DOC: revised io.rst
1 parent 504e69b commit 20aba0f

File tree

1 file changed

+86
-91
lines changed

1 file changed

+86
-91
lines changed

doc/source/io.rst

Lines changed: 86 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ Writing to a file, with a date index and a date column
11011101
11021102
If the JSON serialiser cannot handle the container contents directly it will fallback in the following manner:
11031103

1104-
- if a ``toDict`` method is defined by the unrecognised object then that
1104+
- if a ``toDict`` method is defined by the unrecognised object then that
11051105
will be called and its returned ``dict`` will be JSON serialised.
11061106
- if a ``default_handler`` has been passed to ``to_json`` that will
11071107
be called to convert the object.
@@ -1110,7 +1110,7 @@ If the JSON serialiser cannot handle the container contents directly it will fal
11101110
with an ``OverflowError``.
11111111

11121112
Your best bet when encountering ``OverflowError`` during serialisation
1113-
is to specify a ``default_handler``. For example ``timedelta`` can cause
1113+
is to specify a ``default_handler``. For example ``timedelta`` can cause
11141114
problems:
11151115

11161116
.. ipython:: python
@@ -1597,90 +1597,6 @@ Not escaped:
15971597
Some browsers may not show a difference in the rendering of the previous two
15981598
HTML tables.
15991599

1600-
1601-
Clipboard
1602-
---------
1603-
1604-
.. _io.clipboard:
1605-
1606-
A handy way to grab data is to use the ``read_clipboard`` method, which takes
1607-
the contents of the clipboard buffer and passes them to the ``read_table``
1608-
method. For instance, you can copy the following
1609-
text to the clipboard (CTRL-C on many operating systems):
1610-
1611-
.. code-block:: python
1612-
1613-
A B C
1614-
x 1 4 p
1615-
y 2 5 q
1616-
z 3 6 r
1617-
1618-
And then import the data directly to a DataFrame by calling:
1619-
1620-
.. code-block:: python
1621-
1622-
clipdf = pd.read_clipboard()
1623-
1624-
.. ipython:: python
1625-
1626-
clipdf
1627-
1628-
The ``to_clipboard`` method can be used to write the contents of a DataFrame to
1629-
the clipboard. Following which you can paste the clipboard contents into other
1630-
applications (CTRL-V on many operating systems). Here we illustrate writing a
1631-
DataFrame into clipboard and reading it back.
1632-
1633-
.. ipython:: python
1634-
1635-
df=pd.DataFrame(randn(5,3))
1636-
df
1637-
df.to_clipboard()
1638-
pd.read_clipboard()
1639-
1640-
We can see that we got the same content back, which we had earlier written to the clipboard.
1641-
1642-
.. note::
1643-
1644-
You may need to install xclip or xsel (with gtk or PyQt4 modules) on Linux to use these methods.
1645-
1646-
1647-
.. _io.serialize:
1648-
1649-
Pickling and serialization
1650-
--------------------------
1651-
1652-
All pandas objects are equipped with ``to_pickle`` methods which use Python's
1653-
``cPickle`` module to save data structures to disk using the pickle format.
1654-
1655-
.. ipython:: python
1656-
1657-
df
1658-
df.to_pickle('foo.pkl')
1659-
1660-
The ``read_pickle`` function in the ``pandas`` namespace can be used to load
1661-
any pickled pandas object (or any other pickled object) from file:
1662-
1663-
1664-
.. ipython:: python
1665-
1666-
read_pickle('foo.pkl')
1667-
1668-
.. ipython:: python
1669-
:suppress:
1670-
1671-
import os
1672-
os.remove('foo.pkl')
1673-
1674-
.. warning::
1675-
1676-
Loading pickled data received from untrusted sources can be unsafe.
1677-
1678-
See: http://docs.python.org/2.7/library/pickle.html
1679-
1680-
.. note::
1681-
1682-
These methods were previously ``save`` and ``load``, now deprecated.
1683-
16841600
.. _io.excel:
16851601

16861602
Excel files
@@ -1806,16 +1722,93 @@ module is installed you can use it as a xlsx writer engine as follows:
18061722
18071723
df.to_excel('path_to_file.xlsx', sheet_name='Sheet1')
18081724
1809-
.. _io.hdf5:
1725+
.. _io.clipboard:
18101726

1811-
Serialization
1812-
-------------
1727+
Clipboard
1728+
---------
18131729

1814-
msgpack (experimental)
1815-
~~~~~~~~~~~~~~~~~~~~~~
1730+
A handy way to grab data is to use the ``read_clipboard`` method, which takes
1731+
the contents of the clipboard buffer and passes them to the ``read_table``
1732+
method. For instance, you can copy the following
1733+
text to the clipboard (CTRL-C on many operating systems):
1734+
1735+
.. code-block:: python
1736+
1737+
A B C
1738+
x 1 4 p
1739+
y 2 5 q
1740+
z 3 6 r
1741+
1742+
And then import the data directly to a DataFrame by calling:
1743+
1744+
.. code-block:: python
1745+
1746+
clipdf = pd.read_clipboard()
1747+
1748+
.. ipython:: python
1749+
1750+
clipdf
1751+
1752+
The ``to_clipboard`` method can be used to write the contents of a DataFrame to
1753+
the clipboard. Following which you can paste the clipboard contents into other
1754+
applications (CTRL-V on many operating systems). Here we illustrate writing a
1755+
DataFrame into clipboard and reading it back.
1756+
1757+
.. ipython:: python
1758+
1759+
df=pd.DataFrame(randn(5,3))
1760+
df
1761+
df.to_clipboard()
1762+
pd.read_clipboard()
1763+
1764+
We can see that we got the same content back, which we had earlier written to the clipboard.
1765+
1766+
.. note::
1767+
1768+
You may need to install xclip or xsel (with gtk or PyQt4 modules) on Linux to use these methods.
1769+
1770+
.. _io.pickle:
1771+
1772+
Pickling
1773+
--------
1774+
1775+
All pandas objects are equipped with ``to_pickle`` methods which use Python's
1776+
``cPickle`` module to save data structures to disk using the pickle format.
1777+
1778+
.. ipython:: python
1779+
1780+
df
1781+
df.to_pickle('foo.pkl')
1782+
1783+
The ``read_pickle`` function in the ``pandas`` namespace can be used to load
1784+
any pickled pandas object (or any other pickled object) from file:
1785+
1786+
1787+
.. ipython:: python
1788+
1789+
read_pickle('foo.pkl')
1790+
1791+
.. ipython:: python
1792+
:suppress:
1793+
1794+
import os
1795+
os.remove('foo.pkl')
1796+
1797+
.. warning::
1798+
1799+
Loading pickled data received from untrusted sources can be unsafe.
1800+
1801+
See: http://docs.python.org/2.7/library/pickle.html
1802+
1803+
.. note::
1804+
1805+
These methods were previously ``save`` and ``load``, prior to 0.12.0, and are now deprecated.
18161806

18171807
.. _io.msgpack:
18181808

1809+
msgpack (experimental)
1810+
----------------------
1811+
18191812
.. versionadded:: 0.13.0
18201813

18211814
Starting in 0.13.0, pandas is supporting the ``msgpack`` format for
@@ -1874,6 +1867,8 @@ pandas objects.
18741867
os.remove('foo.msg')
18751868
os.remove('foo2.msg')
18761869
1870+
.. _io.hdf5:
1871+
18771872
HDF5 (PyTables)
18781873
---------------
18791874

0 commit comments

Comments
 (0)