diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 6f74f0393d123..5ab8e89fef987 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -5,12 +5,6 @@ v0.15.0 (October 18, 2014) {{ header }} -.. ipython:: python - :suppress: - - from pandas import * # noqa F401, F403 - - This is a major release from 0.14.1 and includes a small number of API changes, several new features, enhancements, and performance improvements along with a large number of bug fixes. We recommend that all users upgrade to this version. @@ -77,7 +71,8 @@ For full docs, see the :ref:`categorical introduction ` and the .. ipython:: python :okwarning: - df = DataFrame({"id":[1,2,3,4,5,6], "raw_grade":['a', 'b', 'b', 'a', 'a', 'e']}) + df = pd.DataFrame({"id": [1, 2, 3, 4, 5, 6], + "raw_grade": ['a', 'b', 'b', 'a', 'a', 'e']}) df["grade"] = df["raw_grade"].astype("category") df["grade"] @@ -86,7 +81,9 @@ For full docs, see the :ref:`categorical introduction ` and the df["grade"].cat.categories = ["very good", "good", "very bad"] # Reorder the categories and simultaneously add the missing categories - df["grade"] = df["grade"].cat.set_categories(["very bad", "bad", "medium", "good", "very good"]) + df["grade"] = df["grade"].cat.set_categories(["very bad", + "bad", "medium", + "good", "very good"]) df["grade"] df.sort_values("grade") df.groupby("grade").size() @@ -123,7 +120,7 @@ This type is very similar to how ``Timestamp`` works for ``datetimes``. It is a .. code-block:: ipython # Timedelta accessor - In [9]: tds = Timedelta('31 days 5 min 3 sec') + In [9]: tds = pd.Timedelta('31 days 5 min 3 sec') In [10]: tds.minutes Out[10]: 5L @@ -151,22 +148,22 @@ Construct a scalar .. ipython:: python - Timedelta('1 days 06:05:01.00003') - Timedelta('15.5us') - Timedelta('1 hour 15.5us') + pd.Timedelta('1 days 06:05:01.00003') + pd.Timedelta('15.5us') + pd.Timedelta('1 hour 15.5us') # negative Timedeltas have this string repr # to be more consistent with datetime.timedelta conventions - Timedelta('-1us') + pd.Timedelta('-1us') # a NaT - Timedelta('nan') + pd.Timedelta('nan') Access fields for a ``Timedelta`` .. ipython:: python - td = Timedelta('1 hour 3m 15.5us') + td = pd.Timedelta('1 hour 3m 15.5us') td.seconds td.microseconds td.nanoseconds @@ -181,22 +178,22 @@ Construct a ``TimedeltaIndex`` .. ipython:: python - TimedeltaIndex(['1 days','1 days, 00:00:05', - np.timedelta64(2,'D'),timedelta(days=2,seconds=2)]) + pd.TimedeltaIndex(['1 days', '1 days, 00:00:05', + np.timedelta64(2, 'D'), timedelta(days=2, seconds=2)]) Constructing a ``TimedeltaIndex`` with a regular range .. ipython:: python - timedelta_range('1 days',periods=5,freq='D') - timedelta_range(start='1 days',end='2 days',freq='30T') + pd.timedelta_range('1 days', periods=5, freq='D') + pd.timedelta_range(start='1 days', end='2 days', freq='30T') You can now use a ``TimedeltaIndex`` as the index of a pandas object .. ipython:: python - s = Series(np.arange(5), - index=timedelta_range('1 days',periods=5,freq='s')) + s = pd.Series(np.arange(5), + index=pd.timedelta_range('1 days', periods=5, freq='s')) s You can select with partial string selections @@ -210,9 +207,9 @@ Finally, the combination of ``TimedeltaIndex`` with ``DatetimeIndex`` allow cert .. ipython:: python - tdi = TimedeltaIndex(['1 days',pd.NaT,'2 days']) + tdi = pd.TimedeltaIndex(['1 days', pd.NaT, '2 days']) tdi.tolist() - dti = date_range('20130101',periods=3) + dti = pd.date_range('20130101', periods=3) dti.tolist() (dti + tdi).tolist() @@ -235,9 +232,9 @@ A new display option ``display.memory_usage`` (see :ref:`options`) sets the defa dtypes = ['int64', 'float64', 'datetime64[ns]', 'timedelta64[ns]', 'complex128', 'object', 'bool'] n = 5000 - data = dict([ (t, np.random.randint(100, size=n).astype(t)) - for t in dtypes]) - df = DataFrame(data) + data = dict[(t, np.random.randint(100, size=n).astype(t)) + for t in dtypes]) + df = pd.DataFrame(data) df['categorical'] = df['object'].astype('category') df.info() @@ -255,12 +252,12 @@ Additionally :meth:`~pandas.DataFrame.memory_usage` is an available method for a ^^^^^^^^^^^^ ``Series`` has gained an accessor to succinctly return datetime like properties for the *values* of the Series, if its a datetime/period like Series. (:issue:`7207`) -This will return a Series, indexed like the existing Series. See the :ref:`docs ` +This will return a Series, indexed like the existing Series. See the :ref:`docs ` .. ipython:: python # datetime - s = Series(date_range('20130101 09:10:12',periods=4)) + s = pd.Series(pd.date_range('20130101 09:10:12', periods=4)) s s.dt.hour s.dt.second @@ -271,7 +268,7 @@ This enables nice expressions like this: .. ipython:: python - s[s.dt.day==2] + s[s.dt.day == 2] You can easily produce tz aware transformations: @@ -292,7 +289,7 @@ The ``.dt`` accessor works for period and timedelta dtypes. .. ipython:: python # period - s = Series(period_range('20130101',periods=4,freq='D')) + s = pd.Series(pd.period_range('20130101', periods=4, freq='D')) s s.dt.year s.dt.day @@ -300,7 +297,7 @@ The ``.dt`` accessor works for period and timedelta dtypes. .. ipython:: python # timedelta - s = Series(timedelta_range('1 day 00:00:05',periods=4,freq='s')) + s = pd.Series(pd.timedelta_range('1 day 00:00:05', periods=4, freq='s')) s s.dt.days s.dt.seconds @@ -318,11 +315,13 @@ Timezone handling improvements .. ipython:: python :okwarning: - ts = Timestamp('2014-08-01 09:00', tz='US/Eastern') + ts = pd.Timestamp('2014-08-01 09:00', tz='US/Eastern') ts ts.tz_localize(None) - didx = DatetimeIndex(start='2014-08-01 09:00', freq='H', periods=10, tz='US/Eastern') + didx = pd.DatetimeIndex( + start='2014-08-01 09:00', + freq='H', periods=10, tz='US/Eastern') didx didx.tz_localize(None) @@ -353,11 +352,11 @@ Rolling/Expanding Moments improvements .. ipython:: python - s = Series([10, 11, 12, 13]) + s = pd.Series([10, 11, 12, 13]) .. code-block:: ipython - In [15]: rolling_min(s, window=10, min_periods=5) + In [15]: pd.rolling_min(s, window=10, min_periods=5) ValueError: min_periods (5) must be <= window (4) New behavior @@ -398,7 +397,7 @@ Rolling/Expanding Moments improvements .. code-block:: ipython - In [7]: rolling_sum(Series(range(4)), window=3, min_periods=0, center=True) + In [7]: pd.rolling_sum(pd.Series(range(4)), window=3, min_periods=0, center=True) Out[7]: 0 1 1 3 @@ -412,13 +411,13 @@ Rolling/Expanding Moments improvements .. ipython:: python - s = Series([10.5, 8.8, 11.4, 9.7, 9.3]) + s = Series([10.5, 8.8, 11.4, 9.7, 9.3]) Behavior prior to 0.15.0: .. code-block:: ipython - In [39]: rolling_window(s, window=3, win_type='triang', center=True) + In [39]: pd.rolling_window(s, window=3, win_type='triang', center=True) Out[39]: 0 NaN 1 6.583333 @@ -461,19 +460,19 @@ Rolling/Expanding Moments improvements .. ipython:: python - s = Series([1, None, None, None, 2, 3]) + s = Series([1, None, None, None, 2, 3]) .. code-block:: ipython - In [51]: ewma(s, com=3., min_periods=2) - Out[51]: - 0 NaN - 1 NaN - 2 1.000000 - 3 1.000000 - 4 1.571429 - 5 2.189189 - dtype: float64 + In [51]: ewma(s, com=3., min_periods=2) + Out[51]: + 0 NaN + 1 NaN + 2 1.000000 + 3 1.000000 + 4 1.571429 + 5 2.189189 + dtype: float64 New behavior (note values start at index ``4``, the location of the 2nd (since ``min_periods=2``) non-empty value): @@ -503,21 +502,22 @@ Rolling/Expanding Moments improvements .. code-block:: ipython - In [7]: pd.ewma(Series([None, 1., 8.]), com=2.) + In[7]: pd.ewma(pd.Series([None, 1., 8.]), com=2.) Out[7]: 0 NaN 1 1.0 2 5.2 dtype: float64 - In [8]: pd.ewma(Series([1., None, 8.]), com=2., ignore_na=True) # pre-0.15.0 behavior + In [8]: pd.ewma(pd.Series([1., None, 8.]), com=2., ignore_na=True) # pre-0.15.0 behavior Out[8]: 0 1.0 1 1.0 2 5.2 dtype: float64 - In [9]: pd.ewma(Series([1., None, 8.]), com=2., ignore_na=False) # new default + In[9]: pd.ewma(pd.Series([1., None, 8.]), com=2., ignore_na=False) # new default + Out[9]: 0 1.000000 1 1.000000 @@ -554,7 +554,7 @@ Rolling/Expanding Moments improvements .. ipython:: python - s = Series([1., 2., 0., 4.]) + s = pd.Series([1., 2., 0., 4.]) .. code-block:: ipython @@ -668,7 +668,7 @@ Other notable API changes: .. ipython:: python - df = DataFrame([['a'],['b']],index=[1,2]) + df = pd.DataFrame([['a'], ['b']], index=[1, 2]) df In prior versions there was a difference in these two constructs: @@ -687,13 +687,13 @@ Other notable API changes: .. code-block:: ipython - In [3]: df.loc[[1,3]] + In [3]: df.loc[[1, 3]] Out[3]: 0 1 a 3 NaN - In [4]: df.loc[[1,3],:] + In [4]: df.loc[[1, 3], :] Out[4]: 0 1 a @@ -703,10 +703,10 @@ Other notable API changes: .. ipython:: python - p = Panel(np.arange(2*3*4).reshape(2,3,4), - items=['ItemA','ItemB'], - major_axis=[1,2,3], - minor_axis=['A','B','C','D']) + p = pd.Panel(np.arange(2 * 3 * 4).reshape(2, 3, 4), + items=['ItemA', 'ItemB'], + major_axis=[1, 2, 3], + minor_axis=['A', 'B', 'C', 'D']) p The following would raise ``KeyError`` prior to 0.15.0: @@ -725,17 +725,17 @@ Other notable API changes: .. ipython:: python :okexcept: - s = Series(np.arange(3,dtype='int64'), - index=MultiIndex.from_product([['A'],['foo','bar','baz']], - names=['one','two']) - ).sort_index() - s + s = pd.Series(np.arange(3, dtype='int64'), + index=pd.MultiIndex.from_product([['A'], ['foo', 'bar', 'baz']], + names=['one', 'two']) + ).sort_index() + try: - s.loc[['D']] + s.loc[['D']] except KeyError as e: - print("KeyError: " + str(e)) - - Assigning values to ``None`` now considers the dtype when choosing an 'empty' value (:issue:`7941`). + print("KeyError: " + str(e)) + Previously, assigning to ``None`` in numeric containers changed the dtype to object (or errored, depending on the call). It now uses @@ -743,9 +743,9 @@ Other notable API changes: .. ipython:: python - s = Series([1, 2, 3]) - s.loc[0] = None - s + s = pd.Series([1, 2, 3]) + s.loc[0] = None + s ``NaT`` is now used similarly for datetime containers. @@ -754,9 +754,9 @@ Other notable API changes: .. ipython:: python - s = Series(["a", "b", "c"]) - s.loc[0] = None - s + s = pd.Series(["a", "b", "c"]) + s.loc[0] = None + s To insert a ``NaN``, you must explicitly use ``np.nan``. See the :ref:`docs `. @@ -764,22 +764,21 @@ Other notable API changes: .. ipython:: python - s = Series([1, 2, 3]) - s2 = s - s += 1.5 + s = pd.Series([1, 2, 3]) + s2 = s + s += 1.5 Behavior prior to v0.15.0 .. code-block:: ipython - - # the original object - In [5]: s - Out[5]: - 0 2.5 - 1 3.5 - 2 4.5 - dtype: float64 + # the original object + In [5]: s + Out[5]: + 0 2.5 + 1 3.5 + 2 4.5 + dtype: float64 # a reference to the original object @@ -792,13 +791,13 @@ Other notable API changes: This is now the correct behavior - .. ipython:: python + .. ipython:: python - # the original object - s + # the original object + s - # a reference to the original object - s2 + # a reference to the original object + s2 .. _whatsnew_0150.blanklines: @@ -814,13 +813,13 @@ Other notable API changes: In prior versions this would drop the timezone, now it retains the timezone, but gives a column of ``object`` dtype: - .. ipython:: python + .. ipython:: python - i = date_range('1/1/2011', periods=3, freq='10s', tz = 'US/Eastern') - i - df = DataFrame( {'a' : i } ) - df - df.dtypes + i = pd.date_range('1/1/2011', periods=3, freq='10s', tz='US/Eastern') + i + df = pd.DataFrame({'a': i}) + df + df.dtypes Previously this would have yielded a column of ``datetime64`` dtype, but without timezone info. @@ -835,9 +834,9 @@ Other notable API changes: - ``SettingWithCopy`` raise/warnings (according to the option ``mode.chained_assignment``) will now be issued when setting a value on a sliced mixed-dtype DataFrame using chained-assignment. (:issue:`7845`, :issue:`7950`) - .. code-block:: python + .. code-block:: ipython - In [1]: df = DataFrame(np.arange(0,9), columns=['count']) + In [1]: df = pd.DataFrame(np.arange(0, 9), columns=['count']) In [2]: df['group'] = 'b' @@ -853,10 +852,10 @@ Other notable API changes: - Previously an enlargement with a mixed-dtype frame would act unlike ``.append`` which will preserve dtypes (related :issue:`2578`, :issue:`8176`): - .. ipython:: python + .. ipython:: python - df = DataFrame([[True, 1],[False, 2]], - columns=["female","fitness"]) + df = pd.DataFrame([[True, 1], [False, 2]], + columns=["female", "fitness"]) df df.dtypes @@ -913,21 +912,21 @@ Deprecations - The ``Index`` set operations ``+`` and ``-`` were deprecated in order to provide these for numeric type operations on certain index types. ``+`` can be replaced by ``.union()`` or ``|``, and ``-`` by ``.difference()``. Further the method name ``Index.diff()`` is deprecated and can be replaced by ``Index.difference()`` (:issue:`8226`) - .. code-block:: python + .. code-block:: python # + - Index(['a','b','c']) + Index(['b','c','d']) + pd.Index(['a', 'b', 'c']) + pd.Index(['b', 'c', 'd']) # should be replaced by - Index(['a','b','c']).union(Index(['b','c','d'])) + pd.Index(['a', 'b', 'c']).union(pd.Index(['b', 'c', 'd'])) - .. code-block:: python + .. code-block:: python # - - Index(['a','b','c']) - Index(['b','c','d']) + pd.Index(['a', 'b', 'c']) - pd.Index(['b', 'c', 'd']) # should be replaced by - Index(['a','b','c']).difference(Index(['b','c','d'])) + pd.Index(['a', 'b', 'c']).difference(pd.Index(['b', 'c', 'd'])) - The ``infer_types`` argument to :func:`~pandas.read_html` now has no effect and is deprecated (:issue:`7762`, :issue:`7032`). @@ -1049,20 +1048,21 @@ Other: - :func:`set_names`, :func:`set_labels`, and :func:`set_levels` methods now take an optional ``level`` keyword argument to all modification of specific level(s) of a MultiIndex. Additionally :func:`set_names` now accepts a scalar string value when operating on an ``Index`` or on a specific level of a ``MultiIndex`` (:issue:`7792`) - .. ipython:: python + .. ipython:: python - idx = MultiIndex.from_product([['a'], range(3), list("pqr")], names=['foo', 'bar', 'baz']) + idx = pd.MultiIndex.from_product( + [['a'], range(3), list("pqr")], names=['foo', 'bar', 'baz']) idx.set_names('qux', level=0) - idx.set_names(['qux','corge'], level=[0,1]) - idx.set_levels(['a','b','c'], level='bar') - idx.set_levels([['a','b','c'],[1,2,3]], level=[1,2]) + idx.set_names(['qux', 'corge'], level=[0, 1]) + idx.set_levels(['a', 'b', 'c'], level='bar') + idx.set_levels([['a', 'b', 'c'], [1, 2, 3]], level=[1, 2]) - ``Index.isin`` now supports a ``level`` argument to specify which index level to use for membership tests (:issue:`7892`, :issue:`7890`) - .. code-block:: ipython + .. code-block:: ipython - In [1]: idx = MultiIndex.from_product([[0, 1], ['a', 'b', 'c']]) + In [1]: idx = pd.MultiIndex.from_product([[0, 1], ['a', 'b', 'c']]) In [2]: idx.values Out[2]: array([(0, 'a'), (0, 'b'), (0, 'c'), (1, 'a'), (1, 'b'), (1, 'c')], dtype=object) @@ -1072,9 +1072,9 @@ Other: - ``Index`` now supports ``duplicated`` and ``drop_duplicates``. (:issue:`4060`) - .. ipython:: python + .. ipython:: python - idx = Index([1, 2, 3, 4, 1, 2]) + idx = pd.Index([1, 2, 3, 4, 1, 2]) idx idx.duplicated() idx.drop_duplicates() diff --git a/doc/source/whatsnew/v0.15.1.rst b/doc/source/whatsnew/v0.15.1.rst index be7cf04bcdd68..77dd3418ef577 100644 --- a/doc/source/whatsnew/v0.15.1.rst +++ b/doc/source/whatsnew/v0.15.1.rst @@ -5,12 +5,6 @@ v0.15.1 (November 9, 2014) {{ header }} -.. ipython:: python - :suppress: - - from pandas import * # noqa F401, F403 - - This is a minor bug-fix release from 0.15.0 and includes a small number of API changes, several new features, enhancements, and performance improvements along with a large number of bug fixes. We recommend that all users upgrade to this version. @@ -28,7 +22,7 @@ API changes .. ipython:: python - s = Series(date_range('20130101',periods=5,freq='D')) + s = pd.Series(pd.date_range('20130101', periods=5, freq='D')) s.iloc[2] = np.nan s @@ -117,7 +111,6 @@ API changes previous behavior: .. code-block:: ipython - In [8]: s.loc[3.5:1.5] KeyError: 3.5 @@ -156,9 +149,9 @@ API changes In [17]: from pandas.io.data import Options - In [18]: aapl = Options('aapl','yahoo') + In [18]: aapl = Options('aapl', 'yahoo') - In [19]: aapl.get_call_data().iloc[0:5,0:1] + In [19]: aapl.get_call_data().iloc[0:5, 0:1] Out[19]: Last Strike Expiry Type Symbol @@ -183,7 +176,7 @@ API changes 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] + 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 @@ -233,7 +226,7 @@ Enhancements .. ipython:: python - dfi = DataFrame(1,index=pd.MultiIndex.from_product([['a'],range(1000)]),columns=['A']) + dfi = DataFrame(1, index=pd.MultiIndex.from_product([['a'], range(1000)]), columns=['A']) previous behavior: @@ -263,8 +256,8 @@ Enhancements - Added support for 3-character ISO and non-standard country codes in :func:`io.wb.download()` (:issue:`8482`) -- World Bank data requests now will warn/raise based on an ``errors`` argument, as well as a list of hard-coded country codes and +- World Bank data requests now will warn/raise based the World Bank's JSON response. In prior versions, the error messages didn't look at the World Bank's JSON response. Problem-inducing input were simply dropped prior to the request. The issue was that many good countries diff --git a/doc/source/whatsnew/v0.15.2.rst b/doc/source/whatsnew/v0.15.2.rst index 437dd3f8d3df6..c0bd9cbae96f6 100644 --- a/doc/source/whatsnew/v0.15.2.rst +++ b/doc/source/whatsnew/v0.15.2.rst @@ -5,12 +5,6 @@ v0.15.2 (December 12, 2014) {{ header }} -.. ipython:: python - :suppress: - - from pandas import * # noqa F401, F403 - - This is a minor release from 0.15.1 and includes a large number of bug fixes along with several new features, enhancements, and performance improvements. A small number of API changes were necessary to fix existing bugs. @@ -79,7 +73,7 @@ API changes .. ipython:: python - data = pd.DataFrame({'x':[1, 2, 3]}) + data = pd.DataFrame({'x': [1, 2, 3]}) data.y = 2 data['y'] = [2, 4, 6] data diff --git a/setup.cfg b/setup.cfg index a1c82304c5a72..dc88467ad0a01 100644 --- a/setup.cfg +++ b/setup.cfg @@ -46,9 +46,17 @@ ignore = E402, # module level import not at top of file E711, # comparison to none should be 'if cond is none:' exclude = + + doc/source/whatsnew/v0.13.0.rst + doc/source/whatsnew/v0.13.1.rst doc/source/whatsnew/v0.15.0.rst doc/source/whatsnew/v0.15.1.rst doc/source/whatsnew/v0.15.2.rst + doc/source/whatsnew/v0.16.0.rst + doc/source/whatsnew/v0.16.1.rst + doc/source/whatsnew/v0.16.2.rst + doc/source/whatsnew/v0.17.0.rst + doc/source/whatsnew/v0.17.1.rst doc/source/basics.rst doc/source/contributing_docstring.rst doc/source/enhancingperf.rst