Skip to content
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

DOC Add more examples to Series.Resample docstring #10628

Merged
merged 1 commit into from
Sep 1, 2015

Conversation

Winterflower
Copy link
Contributor

Partial fix for #5023
flake8 doesn't do a very good job at checking code in the docstrings for PEP8 compliance, so I'm just eyeballing it at the moment and my PEP8 knowledge leaves something to be desired. Apologies if I missed something really obvious.

@jorisvandenbossche jorisvandenbossche added this to the 0.17.0 milestone Jul 19, 2015

>>> index = pd.date_range('1/1/2000', periods=9, freq='T')
>>> series = pd.Series(range(9), index=index)
>>> print series
Copy link
Member

Choose a reason for hiding this comment

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

Remove print (for py3), only variable name (series) is better.

@Winterflower
Copy link
Contributor Author

Will squash everything into one commit once I add an example of using a custom how method.

@Winterflower
Copy link
Contributor Author

@jorisvandenbossche @sinhrks
this one is done and good to go from my side!
comments/corrections welcome, of course!

Downsample the series into 3 minute bins as above, but label each
bin using the right edge instead of the left.

>>> series.resample('3T', how='sum', label='right')
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you also add how=right' here as well? (I always find that in most common cases you need to specify both)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jorisvandenbossche I'm trying to test some examples with how=right and I am getting exceptions. What is 'how=right supposed to do?

series.resample('3T', how='right', label='right')

Copy link
Member

Choose a reason for hiding this comment

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

oops, sorry, I meant 'closed' instead of 'how'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha no worries! how=right did seem a bit weird. I'll include closed=right in the example.

@jorisvandenbossche
Copy link
Member

Nice examples!

@sinhrks
Copy link
Member

sinhrks commented Aug 5, 2015

Looks nice! No further comments from me.

@jorisvandenbossche
Copy link
Member

@Winterflower Do you have some time to update? (it's only a very small comment)

@Winterflower
Copy link
Contributor Author

@jorisvandenbossche apologies for the delay! I will add the how='right' example tonight after work.

@Winterflower Winterflower force-pushed the pandas-doc-5023 branch 2 times, most recently from 2011483 to 3b25d52 Compare August 30, 2015 10:21
@Winterflower
Copy link
Contributor Author

Still need to fix line lengths.

@Winterflower
Copy link
Contributor Author

At the moment, the doctest for the string is failing because of the custom_resampler function defined in the docstring

Trying:
    def custom_resampler(array_like):
Expecting:
            return np.sum(array_like)+5
**********************************************************************
File "pandas/core/generic.py", line 3367, in generic.NDFrame.resample
Failed example:
    def custom_resampler(array_like):
Exception raised:
    Traceback (most recent call last):
      File "/home/winterflower/anaconda/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest generic.NDFrame.resample[9]>", line 1
        def custom_resampler(array_like):
                                        ^
    SyntaxError: unexpected EOF while parsing

The solution, based on this is to include the ellipsis in the docstring. Will add that to make the doctests pass.

def custom_resampler(array_like):
...     return np.sum(array_like)+5

Add more resample examples

Improve Series examples

Series resample fixes

Fixed breaking docstring issue
@Winterflower
Copy link
Contributor Author

This is good to go on my part!

jreback added a commit that referenced this pull request Sep 1, 2015
DOC Add more examples to Series.Resample docstring
@jreback jreback merged commit 30f672c into pandas-dev:master Sep 1, 2015
@jreback
Copy link
Contributor

jreback commented Sep 1, 2015

@Winterflower gr8 thanks!

Further I think portions of your narrative my be a nice addition to the actual resample docs; add where appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants