From eb54130ed99be17a9d683ee305078bfa1db37827 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 21 Jul 2016 11:28:23 +0200 Subject: [PATCH 1/4] DOC: fix stata versionadded --- pandas/core/frame.py | 5 ++--- pandas/io/stata.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a59668320de3d..628637da59af0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1492,13 +1492,12 @@ def to_stata(self, fname, convert_dates=None, write_index=True, A datetime to use as file creation date. Default is the current time dataset_label : str A label for the data set. Must be 80 characters or smaller. - - .. versionadded:: 0.19.0 - variable_labels : dict Dictionary containing columns as keys and variable labels as values. Each label must be 80 characters or smaller. + .. versionadded:: 0.19.0 + Raises ------ NotImplementedError diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 68a723d399c27..59bc24acac6f8 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -1829,13 +1829,12 @@ class StataWriter(StataParser): A datetime to use as file creation date. Default is the current time dataset_label : str A label for the data set. Must be 80 characters or smaller. - - .. versionadded:: 0.19.0 - variable_labels : dict Dictionary containing columns as keys and variable labels as values. Each label must be 80 characters or smaller. + .. versionadded:: 0.19.0 + Returns ------- writer : StataWriter instance From a374e9183f8c860c0a1cabf9ebeeb39801e32c88 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 21 Jul 2016 11:41:32 +0200 Subject: [PATCH 2/4] DOC: fix sphinx warnings/errors --- doc/source/computation.rst | 16 +++++++--------- doc/source/ecosystem.rst | 6 +++--- doc/source/whatsnew/v0.17.0.txt | 2 +- doc/source/whatsnew/v0.8.0.txt | 3 +-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/doc/source/computation.rst b/doc/source/computation.rst index 12e0ecfba97da..1414d2dd3c8dc 100644 --- a/doc/source/computation.rst +++ b/doc/source/computation.rst @@ -428,15 +428,13 @@ Using a non-regular, but still monotonic index, rolling with an integer window d .. ipython:: python - - dft = DataFrame({'B': [0, 1, 2, np.nan, 4]}, - index = pd.Index([pd.Timestamp('20130101 09:00:00'), - pd.Timestamp('20130101 09:00:02'), - pd.Timestamp('20130101 09:00:03'), - pd.Timestamp('20130101 09:00:05'), - pd.Timestamp('20130101 09:00:06')], - name='foo')) - + dft = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]}, + index = pd.Index([pd.Timestamp('20130101 09:00:00'), + pd.Timestamp('20130101 09:00:02'), + pd.Timestamp('20130101 09:00:03'), + pd.Timestamp('20130101 09:00:05'), + pd.Timestamp('20130101 09:00:06')], + name='foo')) dft dft.rolling(2).sum() diff --git a/doc/source/ecosystem.rst b/doc/source/ecosystem.rst index 0d010b47f393a..17ebd1f163f4f 100644 --- a/doc/source/ecosystem.rst +++ b/doc/source/ecosystem.rst @@ -25,7 +25,7 @@ Statistics and Machine Learning ------------------------------- `Statsmodels `__ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Statsmodels is the prominent python "statistics and econometrics library" and it has a long-standing special relationship with pandas. Statsmodels provides powerful statistics, @@ -78,7 +78,7 @@ more advanced types of plots then those offered by pandas. The `Vincent `__ project leverages `Vega `__ (that in turn, leverages `d3 `__) to create -plots. Although functional, as of Summer 2016 the Vincent project has not been updated +plots. Although functional, as of Summer 2016 the Vincent project has not been updated in over two years and is `unlikely to receive further updates `__. `IPython Vega `__ @@ -130,7 +130,7 @@ qgrid is "an interactive grid for sorting and filtering DataFrames in IPython Notebook" built with SlickGrid. `Spyder `__ -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Spyder is a cross-platform Qt-based open-source Python IDE with editing, testing, debugging, and introspection features. diff --git a/doc/source/whatsnew/v0.17.0.txt b/doc/source/whatsnew/v0.17.0.txt index ef9785d25f014..fc13224d3fe6e 100644 --- a/doc/source/whatsnew/v0.17.0.txt +++ b/doc/source/whatsnew/v0.17.0.txt @@ -965,7 +965,7 @@ Deprecations - ``TimeSeries`` deprecated in favor of ``Series`` (note that this has been an alias since 0.13.0), (:issue:`10890`) - ``SparsePanel`` deprecated and will be removed in a future version (:issue:`11157`). - ``Series.is_time_series`` deprecated in favor of ``Series.index.is_all_dates`` (:issue:`11135`) -- Legacy offsets (like ``'A@JAN'``) listed in :ref:`here ` are deprecated (note that this has been alias since 0.8.0), (:issue:`10878`) +- Legacy offsets (like ``'A@JAN'``) are deprecated (note that this has been alias since 0.8.0) (:issue:`10878`) - ``WidePanel`` deprecated in favor of ``Panel``, ``LongPanel`` in favor of ``DataFrame`` (note these have been aliases since < 0.11.0), (:issue:`10892`) - ``DataFrame.convert_objects`` has been deprecated in favor of type-specific functions ``pd.to_datetime``, ``pd.to_timestamp`` and ``pd.to_numeric`` (new in 0.17.0) (:issue:`11133`). diff --git a/doc/source/whatsnew/v0.8.0.txt b/doc/source/whatsnew/v0.8.0.txt index 0d2cfeb2d7cfc..cf6ac7c1e6ad2 100644 --- a/doc/source/whatsnew/v0.8.0.txt +++ b/doc/source/whatsnew/v0.8.0.txt @@ -134,7 +134,7 @@ Other new features - Move to klib-based hash tables for indexing; better performance and less memory usage than Python's dict - Add first, last, min, max, and prod optimized GroupBy functions -- New :ref:`ordered_merge ` function +- New :ref:`ordered_merge ` function - Add flexible :ref:`comparison ` instance methods eq, ne, lt, gt, etc. to DataFrame, Series - Improve :ref:`scatter_matrix ` plotting @@ -271,4 +271,3 @@ unique. In many cases it will no longer fail (some method like ``append`` still check for uniqueness unless disabled). However, all is not lost: you can inspect ``index.is_unique`` and raise an exception explicitly if it is ``False`` or go to a different code branch. - From 665cee12fa1292ba61965269c656daba67fcfc5c Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 21 Jul 2016 11:51:54 +0200 Subject: [PATCH 3/4] DOC: replace old whatsnew io.data example with plain code-block --- doc/source/whatsnew/v0.15.1.txt | 46 ++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/doc/source/whatsnew/v0.15.1.txt b/doc/source/whatsnew/v0.15.1.txt index 2a4104c2d5dc4..a25e5a80b65fc 100644 --- a/doc/source/whatsnew/v0.15.1.txt +++ b/doc/source/whatsnew/v0.15.1.txt @@ -144,14 +144,46 @@ API changes Current behavior: - .. ipython:: python - :okwarning: + .. code-block:: ipython - from pandas.io.data import Options - aapl = Options('aapl','yahoo') - aapl.get_call_data().iloc[0:5,0:1] - aapl.expiry_dates - aapl.get_near_stock_price(expiry=aapl.expiry_dates[0:3]).iloc[0:5,0:1] + In [17]: from pandas.io.data import Options + + In [18]: aapl = Options('aapl','yahoo') + + In [19]: aapl.get_call_data().iloc[0:5,0:1] + Out[19]: + Last + Strike Expiry Type Symbol + 80 2014-11-14 call AAPL141114C00080000 29.05 + 84 2014-11-14 call AAPL141114C00084000 24.80 + 85 2014-11-14 call AAPL141114C00085000 24.05 + 86 2014-11-14 call AAPL141114C00086000 22.76 + 87 2014-11-14 call AAPL141114C00087000 21.74 + + In [20]: aapl.expiry_dates + Out[20]: + [datetime.date(2014, 11, 14), + datetime.date(2014, 11, 22), + datetime.date(2014, 11, 28), + datetime.date(2014, 12, 5), + datetime.date(2014, 12, 12), + datetime.date(2014, 12, 20), + datetime.date(2015, 1, 17), + datetime.date(2015, 2, 20), + datetime.date(2015, 4, 17), + datetime.date(2015, 7, 17), + datetime.date(2016, 1, 15), + datetime.date(2017, 1, 20)] + + In [21]: aapl.get_near_stock_price(expiry=aapl.expiry_dates[0:3]).iloc[0:5,0:1] + Out[21]: + Last + Strike Expiry Type Symbol + 109 2014-11-22 call AAPL141122C00109000 1.48 + 2014-11-28 call AAPL141128C00109000 1.79 + 110 2014-11-14 call AAPL141114C00110000 0.55 + 2014-11-22 call AAPL141122C00110000 1.02 + 2014-11-28 call AAPL141128C00110000 1.32 See the Options documentation in :ref:`Remote Data ` From 0460f52224d1554480a0b62b3b284996b9486051 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 21 Jul 2016 14:18:37 +0200 Subject: [PATCH 4/4] fix lint issues --- pandas/core/frame.py | 21 ++++++++++++--------- pandas/io/tests/test_stata.py | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 628637da59af0..558d3b1885bf5 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1476,12 +1476,12 @@ def to_stata(self, fname, convert_dates=None, write_index=True, fname : str or buffer String path of file-like object convert_dates : dict - Dictionary mapping columns containing datetime types to stata internal - format to use when wirting the dates. Options are 'tc', 'td', 'tm', - 'tw', 'th', 'tq', 'ty'. Column can be either an integer or a name. - Datetime columns that do not have a conversion type specified will be - converted to 'tc'. Raises NotImplementedError if a datetime column has - timezone information + Dictionary mapping columns containing datetime types to stata + internal format to use when wirting the dates. Options are 'tc', + 'td', 'tm', 'tw', 'th', 'tq', 'ty'. Column can be either an integer + or a name. Datetime columns that do not have a conversion type + specified will be converted to 'tc'. Raises NotImplementedError if + a datetime column has timezone information write_index : bool Write the index to Stata dataset. encoding : str @@ -1489,12 +1489,13 @@ def to_stata(self, fname, convert_dates=None, write_index=True, byteorder : str Can be ">", "<", "little", or "big". default is `sys.byteorder` time_stamp : datetime - A datetime to use as file creation date. Default is the current time + A datetime to use as file creation date. Default is the current + time. dataset_label : str A label for the data set. Must be 80 characters or smaller. variable_labels : dict - Dictionary containing columns as keys and variable labels as values. - Each label must be 80 characters or smaller. + Dictionary containing columns as keys and variable labels as + values. Each label must be 80 characters or smaller. .. versionadded:: 0.19.0 @@ -1509,6 +1510,8 @@ def to_stata(self, fname, convert_dates=None, write_index=True, * Column listed in convert_dates is not in DataFrame * Categorical label contains more than 32,000 characters + .. versionadded:: 0.19.0 + Examples -------- >>> writer = StataWriter('./data_file.dta', data) diff --git a/pandas/io/tests/test_stata.py b/pandas/io/tests/test_stata.py index 009e40c84f94b..2e3182b69acaf 100644 --- a/pandas/io/tests/test_stata.py +++ b/pandas/io/tests/test_stata.py @@ -1204,7 +1204,7 @@ def test_unsupported_datetype(self): with tm.ensure_clean() as path: original.to_stata(path, convert_dates={'dates': 'tC'}) - dates = pd.date_range('1-1-1990',periods=3,tz='Asia/Hong_Kong') + dates = pd.date_range('1-1-1990', periods=3, tz='Asia/Hong_Kong') original = pd.DataFrame({'nums': [1.0, 2.0, 3.0], 'strs': ['apple', 'banana', 'cherry'], 'dates': dates})