From 679059362c2000c19eae01d0d9c63a749e512ca9 Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Tue, 18 Dec 2018 10:05:34 +0530 Subject: [PATCH 01/11] Fixed PEP8 errors in doc/source/whatsnew/v0.15.* --- doc/source/whatsnew/v0.15.0.rst | 80 ++++++++++++++++---------------- doc/source/whatsnew/v0.15.1.rst | 10 ++-- doc/source/whatsnew/v0.15.2.rst | 2 +- doc/test.parquet | Bin 0 -> 897 bytes 4 files changed, 47 insertions(+), 45 deletions(-) create mode 100644 doc/test.parquet diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index e7a7d8a7e3b06..5e451de3f023f 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -7,10 +7,11 @@ v0.15.0 (October 18, 2014) .. 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 +78,7 @@ 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 = 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"] @@ -181,22 +182,22 @@ Construct a ``TimedeltaIndex`` .. ipython:: python - TimedeltaIndex(['1 days','1 days, 00:00:05', - np.timedelta64(2,'D'),timedelta(days=2,seconds=2)]) + 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') + timedelta_range('1 days', periods=5, freq='D') + 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')) + index=timedelta_range('1 days', periods=5, freq='s')) s You can select with partial string selections @@ -210,9 +211,9 @@ Finally, the combination of ``TimedeltaIndex`` with ``DatetimeIndex`` allow cert .. ipython:: python - tdi = TimedeltaIndex(['1 days',pd.NaT,'2 days']) + tdi = TimedeltaIndex(['1 days', pd.NaT, '2 days']) tdi.tolist() - dti = date_range('20130101',periods=3) + dti = date_range('20130101', periods=3) dti.tolist() (dti + tdi).tolist() @@ -235,7 +236,7 @@ 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)) + data = dict([(t, np.random.randint(100, size=n).astype(t)) for t in dtypes]) df = DataFrame(data) df['categorical'] = df['object'].astype('category') @@ -260,7 +261,7 @@ 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 = Series(date_range('20130101 09:10:12', periods=4)) s s.dt.hour s.dt.second @@ -292,7 +293,7 @@ The ``.dt`` accessor works for period and timedelta dtypes. .. ipython:: python # period - s = Series(period_range('20130101',periods=4,freq='D')) + s = Series(period_range('20130101', periods=4, freq='D')) s s.dt.year s.dt.day @@ -300,7 +301,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 = Series(timedelta_range('1 day 00:00:05', periods=4, freq='s')) s s.dt.days s.dt.seconds @@ -667,7 +668,7 @@ Other notable API changes: .. ipython:: python - df = DataFrame([['a'],['b']],index=[1,2]) + df = DataFrame([['a'], ['b']], index=[1, 2]) df In prior versions there was a difference in these two constructs: @@ -686,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 @@ -702,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 = 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: @@ -724,15 +725,15 @@ 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 = Series(np.arange(3, dtype='int64'), + index=MultiIndex.from_product([['A'], ['foo', 'bar', 'baz']], + names=['one', 'two']) + ).sort_index() s try: - s.loc[['D']] + s.loc[['D']] except KeyError as e: - print("KeyError: " + str(e)) + print("KeyError: " + str(e)) - Assigning values to ``None`` now considers the dtype when choosing an 'empty' value (:issue:`7941`). @@ -815,9 +816,9 @@ Other notable API changes: .. ipython:: python - i = date_range('1/1/2011', periods=3, freq='10s', tz = 'US/Eastern') + i = date_range('1/1/2011', periods=3, freq='10s', tz='US/Eastern') i - df = DataFrame( {'a' : i } ) + df = DataFrame({'a': i}) df df.dtypes @@ -836,7 +837,7 @@ Other notable API changes: .. code-block:: python - In [1]: df = DataFrame(np.arange(0,9), columns=['count']) + In [1]: df = DataFrame(np.arange(0, 9), columns=['count']) In [2]: df['group'] = 'b' @@ -854,8 +855,8 @@ Other notable API changes: .. ipython:: python - df = DataFrame([[True, 1],[False, 2]], - columns=["female","fitness"]) + df = DataFrame([[True, 1], [False, 2]], + columns=["female", "fitness"]) df df.dtypes @@ -915,18 +916,18 @@ Deprecations .. code-block:: python # + - Index(['a','b','c']) + Index(['b','c','d']) + Index(['a', 'b', 'c']) + Index(['b', 'c', 'd']) # should be replaced by - Index(['a','b','c']).union(Index(['b','c','d'])) + Index(['a', 'b', 'c']).union(Index(['b', 'c', 'd'])) .. code-block:: python # - - Index(['a','b','c']) - Index(['b','c','d']) + Index(['a', 'b', 'c']) - Index(['b', 'c', 'd']) # should be replaced by - Index(['a','b','c']).difference(Index(['b','c','d'])) + Index(['a', 'b', 'c']).difference(Index(['b', 'c', 'd'])) - The ``infer_types`` argument to :func:`~pandas.read_html` now has no effect and is deprecated (:issue:`7762`, :issue:`7032`). @@ -1050,11 +1051,12 @@ Other: .. ipython:: python - idx = MultiIndex.from_product([['a'], range(3), list("pqr")], names=['foo', 'bar', 'baz']) + idx = 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`) diff --git a/doc/source/whatsnew/v0.15.1.rst b/doc/source/whatsnew/v0.15.1.rst index be7cf04bcdd68..f290ca112e4ad 100644 --- a/doc/source/whatsnew/v0.15.1.rst +++ b/doc/source/whatsnew/v0.15.1.rst @@ -28,7 +28,7 @@ API changes .. ipython:: python - s = Series(date_range('20130101',periods=5,freq='D')) + s = Series(date_range('20130101', periods=5, freq='D')) s.iloc[2] = np.nan s @@ -156,9 +156,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 +183,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 +233,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: diff --git a/doc/source/whatsnew/v0.15.2.rst b/doc/source/whatsnew/v0.15.2.rst index 437dd3f8d3df6..38e325a339282 100644 --- a/doc/source/whatsnew/v0.15.2.rst +++ b/doc/source/whatsnew/v0.15.2.rst @@ -79,7 +79,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/doc/test.parquet b/doc/test.parquet new file mode 100644 index 0000000000000000000000000000000000000000..66540ee4d4d54df5f64fcaacca28ec5ff367b740 GIT binary patch literal 897 zcmb_b%}T>S7~CXFh&L&0NFaw0G!#rjQ(H@=m)?31E!LYz**04ZBx!7tVky1)93DM- z@fAG#BtCJF5KK&;$t0f`SM55&U=(!|Fs9XhXLAVOJ@ zjXi!6eV_5gPx^C!tVn!-eH(|;JG;^x-zHC^$;^#CKh)0E+dD(mvg0V_$QGI&SDKGK zLggCPsDA1Y*B Date: Tue, 18 Dec 2018 18:55:32 +0530 Subject: [PATCH 02/11] Fixed code review faults --- doc/source/whatsnew/v0.15.0.rst | 7 ------- doc/source/whatsnew/v0.15.1.rst | 6 ------ doc/source/whatsnew/v0.15.2.rst | 6 ------ doc/test.parquet | Bin 897 -> 897 bytes setup.cfg | 3 --- 5 files changed, 22 deletions(-) diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 5e451de3f023f..c366ea5dec1f4 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -5,13 +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. diff --git a/doc/source/whatsnew/v0.15.1.rst b/doc/source/whatsnew/v0.15.1.rst index f290ca112e4ad..fc48d5ba8bb33 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. diff --git a/doc/source/whatsnew/v0.15.2.rst b/doc/source/whatsnew/v0.15.2.rst index 38e325a339282..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. diff --git a/doc/test.parquet b/doc/test.parquet index 66540ee4d4d54df5f64fcaacca28ec5ff367b740..81fd7b381b7ec444ace0bb3ba16efab325a235cd 100644 GIT binary patch delta 24 fcmZomu_ZmX<%w;Y-Tjsnb{5iOKSzn delta 24 fcmZo Date: Wed, 19 Dec 2018 23:38:30 +0530 Subject: [PATCH 03/11] Fixed some warnings --- doc/source/whatsnew/v0.15.0.rst | 127 ++++++++++++++++---------------- doc/source/whatsnew/v0.15.1.rst | 7 +- doc/source/whatsnew/v0.15.2.rst | 2 +- doc/test.parquet | Bin 897 -> 0 bytes 4 files changed, 70 insertions(+), 66 deletions(-) delete mode 100644 doc/test.parquet diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index c366ea5dec1f4..f2fcebacf8e2c 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -71,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"] @@ -80,7 +81,8 @@ 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() @@ -117,7 +119,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 @@ -145,22 +147,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 @@ -175,22 +177,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 @@ -229,8 +231,8 @@ 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]) + data = [(t, np.random.randint(100, size=n).astype(t)) + for t in dtypes] df = DataFrame(data) df['categorical'] = df['object'].astype('category') @@ -265,7 +267,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: @@ -315,7 +317,8 @@ Timezone handling improvements ts ts.tz_localize(None) - didx = DatetimeIndex(start='2014-08-01 09:00', freq='H', periods=10, tz='US/Eastern') + didx = DatetimeIndex( + start='2014-08-01 09:00', freq='H', periods=10, tz='US/Eastern') didx didx.tz_localize(None) @@ -718,17 +721,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 = pd.Series(np.arange(3, dtype='int64'), + index=pd.MultiIndex.from_product([['A'], ['foo', 'bar', 'baz']], + names=['one', 'two']) + ).sort_index() s try: s.loc[['D']] except KeyError as e: +- Assigning values to ``None`` now considers the dtype when choosing an 'empty' value (:issue:`7941`). print("KeyError: " + str(e)) -- Assigning values to ``None`` now considers the dtype when choosing an 'empty' value (:issue:`7941`). Previously, assigning to ``None`` in numeric containers changed the dtype to object (or errored, depending on the call). It now uses @@ -736,9 +739,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. @@ -747,9 +750,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 `. @@ -757,22 +760,22 @@ 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 @@ -787,11 +790,11 @@ Other notable API changes: .. 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: @@ -809,11 +812,11 @@ Other notable API changes: .. 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. @@ -830,11 +833,11 @@ Other notable API changes: .. code-block:: python - 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' + In [2]: df['group'] = 'b' - In [3]: df.iloc[0:5]['group'] = 'a' + In [3]: df.iloc[0:5]['group'] = 'a' /usr/local/bin/ipython:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead @@ -848,8 +851,8 @@ Other notable API changes: .. ipython:: python - df = DataFrame([[True, 1], [False, 2]], - columns=["female", "fitness"]) + df = pd.DataFrame([[True, 1], [False, 2]], + columns=["female", "fitness"]) df df.dtypes @@ -909,18 +912,18 @@ Deprecations .. 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 # - - 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`). @@ -1044,8 +1047,8 @@ Other: .. 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') @@ -1056,7 +1059,7 @@ Other: .. 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) @@ -1068,7 +1071,7 @@ Other: .. 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 fc48d5ba8bb33..798abf531bdad 100644 --- a/doc/source/whatsnew/v0.15.1.rst +++ b/doc/source/whatsnew/v0.15.1.rst @@ -22,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 @@ -110,8 +110,8 @@ API changes previous behavior: - .. code-block:: ipython + .. code-block:: ipython In [8]: s.loc[3.5:1.5] KeyError: 3.5 @@ -227,7 +227,8 @@ Enhancements .. ipython:: python - dfi = DataFrame(1, index=pd.MultiIndex.from_product([['a'], range(1000)]), columns=['A']) + dfi = pd.DataFrame( + 1, index=pd.MultiIndex.from_product([['a'], range(1000)]), columns=['A']) previous behavior: diff --git a/doc/source/whatsnew/v0.15.2.rst b/doc/source/whatsnew/v0.15.2.rst index c0bd9cbae96f6..3742cef0f6e8c 100644 --- a/doc/source/whatsnew/v0.15.2.rst +++ b/doc/source/whatsnew/v0.15.2.rst @@ -148,7 +148,7 @@ Other enhancements: .. code-block:: python from sqlalchemy.types import String - data.to_sql('data_dtype', engine, dtype={'Col_1': String}) + data.to_sql('data_dtype', pd.engine, dtype={'Col_1': String}) - ``Series.all`` and ``Series.any`` now support the ``level`` and ``skipna`` parameters (:issue:`8302`): diff --git a/doc/test.parquet b/doc/test.parquet deleted file mode 100644 index 81fd7b381b7ec444ace0bb3ba16efab325a235cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 897 zcmb_b!AiqG6x<|Bs5dEW*gy^;XegM5wl=MmUV7_6v{-KS* zpcpS_a4FXo;(ZBg@kVR$o(27bX92f)RJNcj1mfkc1+W;7@2N)+WQh-XHgr};K!UO& z8$0|Y`Yz*3pX}!VS;1mJe20YionL6K@6acE{4j|l;JWR!2MK=mwe|7n)Bz z%H$f+nEuwK6UY7qty Date: Fri, 21 Dec 2018 09:52:27 +0530 Subject: [PATCH 04/11] Fixed errors --- doc/source/style.ipynb | 1188 ------------------------------- doc/source/whatsnew/v0.15.0.rst | 24 +- 2 files changed, 12 insertions(+), 1200 deletions(-) delete mode 100644 doc/source/style.ipynb diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb deleted file mode 100644 index 792fe5120f6e8..0000000000000 --- a/doc/source/style.ipynb +++ /dev/null @@ -1,1188 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Styling\n", - "\n", - "*New in version 0.17.1*\n", - "\n", - "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", - "\n", - "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", - "\n", - "You can apply **conditional formatting**, the visual styling of a DataFrame\n", - "depending on the data within, by using the ``DataFrame.style`` property.\n", - "This is a property that returns a ``Styler`` object, which has\n", - "useful methods for formatting and displaying DataFrames.\n", - "\n", - "The styling is accomplished using CSS.\n", - "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", - "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Building Styles\n", - "\n", - "Pass your style functions into one of the following methods:\n", - "\n", - "- ``Styler.applymap``: elementwise\n", - "- ``Styler.apply``: column-/row-/table-wise\n", - "\n", - "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", - "`Styler.applymap` works through the DataFrame elementwise.\n", - "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", - "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", - "\n", - "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", - "\n", - "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", - "\n", - "Let's see some examples." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "nbsphinx": "hidden" - }, - "outputs": [], - "source": [ - "import matplotlib.pyplot\n", - "# We have this here to trigger matplotlib's font cache stuff.\n", - "# This cell is hidden from the output" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd\n", - "import numpy as np\n", - "\n", - "np.random.seed(24)\n", - "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", - "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", - " axis=1)\n", - "df.iloc[0, 2] = np.nan" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a boring example of rendering a DataFrame, without any (visible) styles:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", - "\n", - "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.style.highlight_null().render().split('\\n')[:10]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", - "\n", - "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's write a simple style function that will color negative numbers red and positive numbers black." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def color_negative_red(val):\n", - " \"\"\"\n", - " Takes a scalar and returns a string with\n", - " the css property `'color: red'` for negative\n", - " strings, black otherwise.\n", - " \"\"\"\n", - " color = 'red' if val < 0 else 'black'\n", - " return 'color: %s' % color" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, the cell's style depends only on it's own value.\n", - "That means we should use the `Styler.applymap` method which works elementwise." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s = df.style.applymap(color_negative_red)\n", - "s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to reuse your existing knowledge of how to interact with DataFrames.\n", - "\n", - "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.0" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 1dead39954675..415744174830e 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -737,18 +737,18 @@ Other notable API changes: dtype to object (or errored, depending on the call). It now uses ``NaN``: - .. ipython:: python + .. ipython:: python - s = pd.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. For object containers, we now preserve ``None`` values (previously these were converted to ``NaN`` values). - .. ipython:: python + .. ipython:: python s = pd.Series(["a", "b", "c"]) s.loc[0] = None @@ -758,7 +758,7 @@ Other notable API changes: - In prior versions, updating a pandas object inplace would not reflect in other python references to this object. (:issue:`8511`, :issue:`5104`) - .. ipython:: python + .. ipython:: python s = pd.Series([1, 2, 3]) s2 = s @@ -766,7 +766,7 @@ Other notable API changes: Behavior prior to v0.15.0 - .. code-block:: ipython + .. code-block:: ipython # the original object @@ -788,7 +788,7 @@ Other notable API changes: This is now the correct behavior - .. ipython:: python + .. ipython:: python # the original object s @@ -810,7 +810,7 @@ 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 = pd.date_range('1/1/2011', periods=3, freq='10s', tz='US/Eastern') i @@ -833,11 +833,11 @@ Other notable API changes: .. code-block:: python - In [1]: df = pd.DataFrame(np.arange(0, 9), columns=['count']) + In [1]: df = pd.DataFrame(np.arange(0, 9), columns=['count']) - In [2]: df['group'] = 'b' + In [2]: df['group'] = 'b' - In [3]: df.iloc[0:5]['group'] = 'a' + In [3]: df.iloc[0:5]['group'] = 'a' /usr/local/bin/ipython:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead From 4ccd59130e1f2cdbe2c6fab790052faec4672a07 Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Sat, 22 Dec 2018 12:15:58 +0530 Subject: [PATCH 05/11] Restored style.ipynb --- doc/source/style.ipynb | 1188 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1188 insertions(+) create mode 100644 doc/source/style.ipynb diff --git a/doc/source/style.ipynb b/doc/source/style.ipynb new file mode 100644 index 0000000000000..792fe5120f6e8 --- /dev/null +++ b/doc/source/style.ipynb @@ -0,0 +1,1188 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Styling\n", + "\n", + "*New in version 0.17.1*\n", + "\n", + "*Provisional: This is a new feature and still under development. We'll be adding features and possibly making breaking changes in future releases. We'd love to hear your feedback.*\n", + "\n", + "This document is written as a Jupyter Notebook, and can be viewed or downloaded [here](http://nbviewer.ipython.org/github/pandas-dev/pandas/blob/master/doc/source/style.ipynb).\n", + "\n", + "You can apply **conditional formatting**, the visual styling of a DataFrame\n", + "depending on the data within, by using the ``DataFrame.style`` property.\n", + "This is a property that returns a ``Styler`` object, which has\n", + "useful methods for formatting and displaying DataFrames.\n", + "\n", + "The styling is accomplished using CSS.\n", + "You write \"style functions\" that take scalars, `DataFrame`s or `Series`, and return *like-indexed* DataFrames or Series with CSS `\"attribute: value\"` pairs for the values.\n", + "These functions can be incrementally passed to the `Styler` which collects the styles before rendering." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Building Styles\n", + "\n", + "Pass your style functions into one of the following methods:\n", + "\n", + "- ``Styler.applymap``: elementwise\n", + "- ``Styler.apply``: column-/row-/table-wise\n", + "\n", + "Both of those methods take a function (and some other keyword arguments) and applies your function to the DataFrame in a certain way.\n", + "`Styler.applymap` works through the DataFrame elementwise.\n", + "`Styler.apply` passes each column or row into your DataFrame one-at-a-time or the entire table at once, depending on the `axis` keyword argument.\n", + "For columnwise use `axis=0`, rowwise use `axis=1`, and for the entire table at once use `axis=None`.\n", + "\n", + "For `Styler.applymap` your function should take a scalar and return a single string with the CSS attribute-value pair.\n", + "\n", + "For `Styler.apply` your function should take a Series or DataFrame (depending on the axis parameter), and return a Series or DataFrame with an identical shape where each value is a string with a CSS attribute-value pair.\n", + "\n", + "Let's see some examples." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "nbsphinx": "hidden" + }, + "outputs": [], + "source": [ + "import matplotlib.pyplot\n", + "# We have this here to trigger matplotlib's font cache stuff.\n", + "# This cell is hidden from the output" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "np.random.seed(24)\n", + "df = pd.DataFrame({'A': np.linspace(1, 10, 10)})\n", + "df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],\n", + " axis=1)\n", + "df.iloc[0, 2] = np.nan" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here's a boring example of rendering a DataFrame, without any (visible) styles:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.style" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "*Note*: The `DataFrame.style` attribute is a property that returns a `Styler` object. `Styler` has a `_repr_html_` method defined on it so they are rendered automatically. If you want the actual HTML back for further processing or for writing to file call the `.render()` method which returns a string.\n", + "\n", + "The above output looks very similar to the standard DataFrame HTML representation. But we've done some work behind the scenes to attach CSS classes to each cell. We can view these by calling the `.render` method." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.style.highlight_null().render().split('\\n')[:10]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The `row0_col2` is the identifier for that particular cell. We've also prepended each row/column identifier with a UUID unique to each DataFrame so that the style from one doesn't collide with the styling from another within the same notebook or page (you can set the `uuid` if you'd like to tie together the styling of two DataFrames).\n", + "\n", + "When writing style functions, you take care of producing the CSS attribute / value pairs you want. Pandas matches those up with the CSS classes that identify each cell." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's write a simple style function that will color negative numbers red and positive numbers black." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def color_negative_red(val):\n", + " \"\"\"\n", + " Takes a scalar and returns a string with\n", + " the css property `'color: red'` for negative\n", + " strings, black otherwise.\n", + " \"\"\"\n", + " color = 'red' if val < 0 else 'black'\n", + " return 'color: %s' % color" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this case, the cell's style depends only on it's own value.\n", + "That means we should use the `Styler.applymap` method which works elementwise." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s = df.style.applymap(color_negative_red)\n", + "s" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Notice the similarity with the standard `df.applymap`, which operates on DataFrames elementwise. We want you to be able to reuse your existing knowledge of how to interact with DataFrames.\n", + "\n", + "Notice also that our function returned a string containing the CSS attribute and value, separated by a colon just like in a `'.format(css))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.0" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} From 870e0b7118a9043d681eb80823a317c6d2293c18 Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Sun, 23 Dec 2018 09:33:26 +0530 Subject: [PATCH 06/11] Fixed all undefined errors --- doc/source/whatsnew/v0.15.0.rst | 62 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 415744174830e..226c21fc21dea 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -206,9 +206,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() @@ -233,7 +233,7 @@ A new display option ``display.memory_usage`` (see :ref:`options`) sets the defa n = 5000 data = [(t, np.random.randint(100, size=n).astype(t)) for t in dtypes] - df = DataFrame(data) + df = pd.DataFrame(data) df['categorical'] = df['object'].astype('category') df.info() @@ -256,7 +256,7 @@ 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 @@ -288,7 +288,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 @@ -296,7 +296,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 @@ -313,11 +313,11 @@ Timezone handling improvements .. ipython:: python - 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( + didx = pd.DatetimeIndex( start='2014-08-01 09:00', freq='H', periods=10, tz='US/Eastern') didx didx.tz_localize(None) @@ -349,11 +349,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 @@ -394,7 +394,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 @@ -414,7 +414,7 @@ Rolling/Expanding Moments improvements .. 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 @@ -499,21 +499,21 @@ 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 @@ -550,7 +550,7 @@ Rolling/Expanding Moments improvements .. ipython:: python - s = Series([1., 2., 0., 4.]) + s = pd.Series([1., 2., 0., 4.]) .. code-block:: ipython @@ -608,8 +608,8 @@ Improvements in the sql io module .. code-block:: python - df.to_sql('table', engine, schema='other_schema') - pd.read_sql_table('table', engine, schema='other_schema') + df.to_sql('table', pd.engine, schema='other_schema') + pd.read_sql_table('table', pd.engine, schema='other_schema') - Added support for writing ``NaN`` values with ``to_sql`` (:issue:`2754`). - Added support for writing datetime64 columns with ``to_sql`` for all database flavors (:issue:`7103`). @@ -664,7 +664,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: @@ -699,10 +699,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,7 +725,7 @@ Other notable API changes: index=pd.MultiIndex.from_product([['A'], ['foo', 'bar', 'baz']], names=['one', 'two']) ).sort_index() - s + try: s.loc[['D']] except KeyError as e: @@ -831,7 +831,7 @@ 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 = pd.DataFrame(np.arange(0, 9), columns=['count']) @@ -849,7 +849,7 @@ 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 = pd.DataFrame([[True, 1], [False, 2]], columns=["female", "fitness"]) @@ -909,7 +909,7 @@ 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 # + pd.Index(['a', 'b', 'c']) + pd.Index(['b', 'c', 'd']) @@ -917,7 +917,7 @@ Deprecations # should be replaced by pd.Index(['a', 'b', 'c']).union(pd.Index(['b', 'c', 'd'])) - .. code-block:: python + .. code-block:: python # - pd.Index(['a', 'b', 'c']) - pd.Index(['b', 'c', 'd']) @@ -1045,7 +1045,7 @@ 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 = pd.MultiIndex.from_product( [['a'], range(3), list("pqr")], names=['foo', 'bar', 'baz']) @@ -1057,7 +1057,7 @@ Other: - ``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 = pd.MultiIndex.from_product([[0, 1], ['a', 'b', 'c']]) @@ -1069,7 +1069,7 @@ Other: - ``Index`` now supports ``duplicated`` and ``drop_duplicates``. (:issue:`4060`) - .. ipython:: python + .. ipython:: python idx = pd.Index([1, 2, 3, 4, 1, 2]) idx From 458ad38aff7b5312e8a20f6f919273b36f19bf93 Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Sun, 23 Dec 2018 21:42:32 +0530 Subject: [PATCH 07/11] Fixed all 0.15.1 errors --- doc/source/whatsnew/v0.15.0.rst | 3 ++- doc/source/whatsnew/v0.15.1.rst | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 226c21fc21dea..40e4954bf0712 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -506,7 +506,8 @@ Rolling/Expanding Moments improvements 2 5.2 dtype: float64 - In [8]: pd.ewma(pd.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 diff --git a/doc/source/whatsnew/v0.15.1.rst b/doc/source/whatsnew/v0.15.1.rst index 798abf531bdad..85c0b7a82f013 100644 --- a/doc/source/whatsnew/v0.15.1.rst +++ b/doc/source/whatsnew/v0.15.1.rst @@ -24,6 +24,8 @@ API changes s = pd.Series(pd.date_range('20130101', periods=5, freq='D')) s.iloc[2] = np.nan + df = pd.DataFrame(); + ts = pd .Timestamp(); s previous behavior: From d81927c893f49d0b6de739ebd2602d413f0552b6 Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Sun, 23 Dec 2018 23:46:57 +0530 Subject: [PATCH 08/11] Fixed 0.15.1 errors --- doc/source/whatsnew/v0.15.1.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.15.1.rst b/doc/source/whatsnew/v0.15.1.rst index 85c0b7a82f013..884ddf76e39b6 100644 --- a/doc/source/whatsnew/v0.15.1.rst +++ b/doc/source/whatsnew/v0.15.1.rst @@ -17,6 +17,10 @@ users upgrade to this version. API changes ~~~~~~~~~~~ + .. ipython:: python + :supress: + df = pd.DataFrame() + ts = pd.Timestamp() - ``s.dt.hour`` and other ``.dt`` accessors will now return ``np.nan`` for missing values (rather than previously -1), (:issue:`8689`) @@ -24,8 +28,6 @@ API changes s = pd.Series(pd.date_range('20130101', periods=5, freq='D')) s.iloc[2] = np.nan - df = pd.DataFrame(); - ts = pd .Timestamp(); s previous behavior: From dc8bb825c16755f92c42e33ea6e34e95a38d679b Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Wed, 2 Jan 2019 10:03:30 +0530 Subject: [PATCH 09/11] Fixed pep-8 errors --- doc/source/whatsnew/v0.15.0.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 40e4954bf0712..1bc2ca959e569 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -81,8 +81,10 @@ 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() @@ -499,7 +501,7 @@ Rolling/Expanding Moments improvements .. code-block:: ipython - In [7]: pd.ewma(pd.Series([None, 1., 8.]), com=2.) + In[7]: pd.ewma(pd.Series([None, 1., 8.]), com=2.) Out[7]: 0 NaN 1 1.0 @@ -514,7 +516,9 @@ Rolling/Expanding Moments improvements 2 5.2 dtype: float64 - In [9]: pd.ewma(pd.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 @@ -726,7 +730,7 @@ Other notable API changes: index=pd.MultiIndex.from_product([['A'], ['foo', 'bar', 'baz']], names=['one', 'two']) ).sort_index() - + try: s.loc[['D']] except KeyError as e: @@ -738,7 +742,7 @@ Other notable API changes: dtype to object (or errored, depending on the call). It now uses ``NaN``: - .. ipython:: python + .. ipython:: python s = pd.Series([1, 2, 3]) s.loc[0] = None @@ -749,7 +753,7 @@ Other notable API changes: For object containers, we now preserve ``None`` values (previously these were converted to ``NaN`` values). - .. ipython:: python + .. ipython:: python s = pd.Series(["a", "b", "c"]) s.loc[0] = None @@ -759,7 +763,7 @@ Other notable API changes: - In prior versions, updating a pandas object inplace would not reflect in other python references to this object. (:issue:`8511`, :issue:`5104`) - .. ipython:: python + .. ipython:: python s = pd.Series([1, 2, 3]) s2 = s From 50a0699fe076a068561d351ffdafeafaa74a64af Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Fri, 4 Jan 2019 11:09:59 +0530 Subject: [PATCH 10/11] Changes pushed to v0.15 --- doc/source/whatsnew/v0.15.0.rst | 47 +++++++++++++++------------------ doc/source/whatsnew/v0.15.1.rst | 10 ++----- doc/source/whatsnew/v0.15.2.rst | 2 +- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/doc/source/whatsnew/v0.15.0.rst b/doc/source/whatsnew/v0.15.0.rst index 296fe30c02e53..5ab8e89fef987 100644 --- a/doc/source/whatsnew/v0.15.0.rst +++ b/doc/source/whatsnew/v0.15.0.rst @@ -83,8 +83,7 @@ For full docs, see the :ref:`categorical introduction ` and the # Reorder the categories and simultaneously add the missing categories df["grade"] = df["grade"].cat.set_categories(["very bad", "bad", "medium", - "good", "very good"] - ) + "good", "very good"]) df["grade"] df.sort_values("grade") df.groupby("grade").size() @@ -233,8 +232,8 @@ 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 = [(t, np.random.randint(100, size=n).astype(t)) - for t in dtypes] + 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') @@ -253,8 +252,8 @@ 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 @@ -321,7 +320,8 @@ Timezone handling improvements ts.tz_localize(None) didx = pd.DatetimeIndex( - start='2014-08-01 09:00', freq='H', periods=10, tz='US/Eastern') + start='2014-08-01 09:00', + freq='H', periods=10, tz='US/Eastern') didx didx.tz_localize(None) @@ -411,7 +411,7 @@ 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: @@ -460,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): @@ -509,16 +509,14 @@ Rolling/Expanding Moments improvements 2 5.2 dtype: float64 - In [8]: pd.ewma(pd.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( - pd.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 @@ -614,8 +612,8 @@ Improvements in the sql io module .. code-block:: python - df.to_sql('table', pd.engine, schema='other_schema') - pd.read_sql_table('table', pd.engine, schema='other_schema') + df.to_sql('table', engine, schema='other_schema') + pd.read_sql_table('table', engine, schema='other_schema') - Added support for writing ``NaN`` values with ``to_sql`` (:issue:`2754`). - Added support for writing datetime64 columns with ``to_sql`` for all database flavors (:issue:`7103`). @@ -772,8 +770,7 @@ Other notable API changes: Behavior prior to v0.15.0 - .. code-block:: ipython - + .. code-block:: ipython # the original object In [5]: s diff --git a/doc/source/whatsnew/v0.15.1.rst b/doc/source/whatsnew/v0.15.1.rst index 884ddf76e39b6..77dd3418ef577 100644 --- a/doc/source/whatsnew/v0.15.1.rst +++ b/doc/source/whatsnew/v0.15.1.rst @@ -17,10 +17,6 @@ users upgrade to this version. API changes ~~~~~~~~~~~ - .. ipython:: python - :supress: - df = pd.DataFrame() - ts = pd.Timestamp() - ``s.dt.hour`` and other ``.dt`` accessors will now return ``np.nan`` for missing values (rather than previously -1), (:issue:`8689`) @@ -114,7 +110,6 @@ API changes previous behavior: - .. code-block:: ipython In [8]: s.loc[3.5:1.5] KeyError: 3.5 @@ -231,8 +226,7 @@ Enhancements .. ipython:: python - dfi = pd.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: @@ -262,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 3742cef0f6e8c..c0bd9cbae96f6 100644 --- a/doc/source/whatsnew/v0.15.2.rst +++ b/doc/source/whatsnew/v0.15.2.rst @@ -148,7 +148,7 @@ Other enhancements: .. code-block:: python from sqlalchemy.types import String - data.to_sql('data_dtype', pd.engine, dtype={'Col_1': String}) + data.to_sql('data_dtype', engine, dtype={'Col_1': String}) - ``Series.all`` and ``Series.any`` now support the ``level`` and ``skipna`` parameters (:issue:`8302`): From 9ba2eabf83dc0e320441360dbdb9611509fe518b Mon Sep 17 00:00:00 2001 From: Joy Bhalla Date: Fri, 4 Jan 2019 11:13:23 +0530 Subject: [PATCH 11/11] Fixed setup.cfg --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index 9d7b4e72588a5..aee8d9271f1e2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,9 @@ 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