@@ -1101,7 +1101,7 @@ Writing to a file, with a date index and a date column
1101
1101
1102
1102
If the JSON serialiser cannot handle the container contents directly it will fallback in the following manner:
1103
1103
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
1105
1105
will be called and its returned ``dict `` will be JSON serialised.
1106
1106
- if a ``default_handler `` has been passed to ``to_json `` that will
1107
1107
be called to convert the object.
@@ -1110,7 +1110,7 @@ If the JSON serialiser cannot handle the container contents directly it will fal
1110
1110
with an ``OverflowError ``.
1111
1111
1112
1112
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
1114
1114
problems:
1115
1115
1116
1116
.. ipython :: python
@@ -1597,90 +1597,6 @@ Not escaped:
1597
1597
Some browsers may not show a difference in the rendering of the previous two
1598
1598
HTML tables.
1599
1599
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
-
1684
1600
.. _io.excel :
1685
1601
1686
1602
Excel files
@@ -1806,16 +1722,93 @@ module is installed you can use it as a xlsx writer engine as follows:
1806
1722
1807
1723
df.to_excel(' path_to_file.xlsx' , sheet_name = ' Sheet1' )
1808
1724
1809
- .. _io.hdf5 :
1725
+ .. _io.clipboard :
1810
1726
1811
- Serialization
1812
- -------------
1727
+ Clipboard
1728
+ ---------
1813
1729
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.
1816
1806
1817
1807
.. _io.msgpack :
1818
1808
1809
+ msgpack (experimental)
1810
+ ----------------------
1811
+
1819
1812
.. versionadded :: 0.13.0
1820
1813
1821
1814
Starting in 0.13.0, pandas is supporting the ``msgpack `` format for
@@ -1874,6 +1867,8 @@ pandas objects.
1874
1867
os.remove(' foo.msg' )
1875
1868
os.remove(' foo2.msg' )
1876
1869
1870
+ .. _io.hdf5 :
1871
+
1877
1872
HDF5 (PyTables)
1878
1873
---------------
1879
1874
0 commit comments