From 70231469c8b866dd4aa93c19d51cdf67a3184261 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Wed, 22 Jan 2020 10:44:15 +0100 Subject: [PATCH 1/2] DOC Remove Python 2 specific comments from documentation --- doc/source/getting_started/install.rst | 1 - doc/source/user_guide/enhancingperf.rst | 5 ----- doc/source/user_guide/io.rst | 17 +++-------------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index b5c512cdc8328..25b499a46ffaf 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -146,7 +146,6 @@ Installing using your Linux distribution's package manager. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The commands in this table will install pandas for Python 3 from your distribution. -To install pandas for Python 2, you may need to use the ``python-pandas`` package. .. csv-table:: :header: "Distribution", "Status", "Download / Repository Link", "Install method" diff --git a/doc/source/user_guide/enhancingperf.rst b/doc/source/user_guide/enhancingperf.rst index 2df5b9d82dcc3..22ef4ccd6f07f 100644 --- a/doc/source/user_guide/enhancingperf.rst +++ b/doc/source/user_guide/enhancingperf.rst @@ -78,11 +78,6 @@ four calls) using the `prun ipython magic function ` is an informal performance comparison for some of these IO methods. -.. note:: - For examples that use the ``StringIO`` class, make sure you import it - according to your Python version, i.e. ``from StringIO import StringIO`` for - Python 2 and ``from io import StringIO`` for Python 3. - .. _io.read_csv_table: CSV & text files @@ -915,9 +910,7 @@ data columns: .. note:: When passing a dict as the `parse_dates` argument, the order of - the columns prepended is not guaranteed, because `dict` objects do not impose - an ordering on their keys. On Python 2.7+ you may use `collections.OrderedDict` - instead of a regular `dict` if this matters to you. Because of this, when using a + the columns prepended is not guaranteed. Because of this, when using a dict for 'parse_dates' in conjunction with the `index_col` argument, it's best to specify `index_col` as a column label rather then as an index on the resulting frame. @@ -2453,7 +2446,7 @@ Specify a number of rows to skip: dfs = pd.read_html(url, skiprows=0) -Specify a number of rows to skip using a list (``xrange`` (Python 2 only) works +Specify a number of rows to skip using a list (``range`` works as well): .. code-block:: python @@ -3124,11 +3117,7 @@ Pandas supports writing Excel files to buffer-like objects such as ``StringIO`` .. code-block:: python - # Safe import for either Python 2.x or 3.x - try: - from io import BytesIO - except ImportError: - from cStringIO import StringIO as BytesIO + from io import BytesIO bio = BytesIO() From 68266b07bb8f70c0e07708aa618e72a6a76d18a8 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Sat, 25 Jan 2020 12:21:07 +0100 Subject: [PATCH 2/2] Address review comments --- doc/source/user_guide/io.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index b0367c8e4851b..22bf34c40abc5 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -39,6 +39,10 @@ The pandas I/O API is a set of top level ``reader`` functions accessed like :ref:`Here ` is an informal performance comparison for some of these IO methods. +.. note:: + For examples that use the ``StringIO`` class, make sure you import it + with ``from io import StringIO`` for Python 3. + .. _io.read_csv_table: CSV & text files @@ -907,14 +911,6 @@ data columns: significantly faster, ~20x has been observed. -.. note:: - - When passing a dict as the `parse_dates` argument, the order of - the columns prepended is not guaranteed. Because of this, when using a - dict for 'parse_dates' in conjunction with the `index_col` argument, it's best to - specify `index_col` as a column label rather then as an index on the resulting frame. - - Date parsing functions ++++++++++++++++++++++