From 9a353d1178f84431ebbd3b629e6bb1fe6b91ae8c Mon Sep 17 00:00:00 2001 From: Fabian Haase Date: Sun, 25 Nov 2018 17:02:42 +0100 Subject: [PATCH 1/2] Fix PEP-8 issues in comparison_with_sas.rst Signed-off-by: Fabian Haase --- doc/source/comparison_with_sas.rst | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/doc/source/comparison_with_sas.rst b/doc/source/comparison_with_sas.rst index 318bffe44a81b..727bc59fb002d 100644 --- a/doc/source/comparison_with_sas.rst +++ b/doc/source/comparison_with_sas.rst @@ -105,9 +105,7 @@ and the values are the data. .. ipython:: python - df = pd.DataFrame({ - 'x': [1, 3, 5], - 'y': [2, 4, 6]}) + df = pd.DataFrame({'x': [1, 3, 5], 'y': [2, 4, 6]}) df @@ -131,7 +129,8 @@ The pandas method is :func:`read_csv`, which works similarly. .. ipython:: python - url = 'https://raw.github.com/pandas-dev/pandas/master/pandas/tests/data/tips.csv' + url = 'https://raw.github.com/pandas-dev/' \ + 'pandas/master/pandas/tests/data/tips.csv' tips = pd.read_csv(url) tips.head() @@ -289,17 +288,17 @@ see the :ref:`timeseries documentation` for more details. tips['date1_year'] = tips['date1'].dt.year tips['date2_month'] = tips['date2'].dt.month tips['date1_next'] = tips['date1'] + pd.offsets.MonthBegin() - tips['months_between'] = (tips['date2'].dt.to_period('M') - - tips['date1'].dt.to_period('M')) + tips['months_between'] = ( + tips['date2'].dt.to_period('M') - tips['date1'].dt.to_period('M')) - tips[['date1','date2','date1_year','date2_month', - 'date1_next','months_between']].head() + tips[['date1', 'date2', 'date1_year', 'date2_month', + 'date1_next', 'months_between']].head() .. ipython:: python :suppress: - tips = tips.drop(['date1','date2','date1_year', - 'date2_month','date1_next','months_between'], axis=1) + tips = tips.drop(['date1', 'date2', 'date1_year', + 'date2_month', 'date1_next', 'months_between'], axis=1) Selection of Columns ~~~~~~~~~~~~~~~~~~~~ @@ -335,7 +334,7 @@ The same operations are expressed in pandas below. tips.drop('sex', axis=1).head() # rename - tips.rename(columns={'total_bill':'total_bill_2'}).head() + tips.rename(columns={'total_bill': 'total_bill_2'}).head() Sorting by Values @@ -508,7 +507,7 @@ The following tables will be used in the merge examples 'value': np.random.randn(4)}) df1 df2 = pd.DataFrame({'key': ['B', 'D', 'D', 'E'], - 'value': np.random.randn(4)}) + 'value': np.random.randn(4)}) df2 In SAS, data must be explicitly sorted before merging. Different @@ -695,7 +694,7 @@ In pandas this would be written as: .. ipython:: python - tips.groupby(['sex','smoker']).first() + tips.groupby(['sex', 'smoker']).first() Other Considerations From 8bad7adc9a3c826323bb156d84f0d154f05b5cb4 Mon Sep 17 00:00:00 2001 From: Fabian Haase Date: Sun, 25 Nov 2018 21:07:29 +0100 Subject: [PATCH 2/2] Review of @datapythonista Signed-off-by: Fabian Haase --- doc/source/comparison_with_sas.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/comparison_with_sas.rst b/doc/source/comparison_with_sas.rst index 727bc59fb002d..c4d121c10538c 100644 --- a/doc/source/comparison_with_sas.rst +++ b/doc/source/comparison_with_sas.rst @@ -129,8 +129,8 @@ The pandas method is :func:`read_csv`, which works similarly. .. ipython:: python - url = 'https://raw.github.com/pandas-dev/' \ - 'pandas/master/pandas/tests/data/tips.csv' + url = ('https://raw.github.com/pandas-dev/' + 'pandas/master/pandas/tests/data/tips.csv') tips = pd.read_csv(url) tips.head()