Skip to content

DOC: Fix PEP-8 issues in comparison_with_sas.rst #23902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions doc/source/comparison_with_sas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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/' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd instead use (backslashes are discouraged in Python):

url = ('https://raw.github.com/pandas-dev/'
       'pandas/master/pandas/tests/data/tips.csv')

'pandas/master/pandas/tests/data/tips.csv'
tips = pd.read_csv(url)
tips.head()

Expand Down Expand Up @@ -289,17 +288,17 @@ see the :ref:`timeseries documentation<timeseries>` 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
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down