Skip to content

Resolution docstring #21122

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 21 commits into from
Jul 8, 2018
Merged

Conversation

chalmerlowe
Copy link
Contributor

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry
################################################################################
################### Docstring (pandas.Timedelta.resolution)  ###################
################################################################################

Return a string representing the lowest (i.e. smallest) time resolution.

Each timedelta has a defined resolution that represents the lowest OR
most granular level of precision. Each level of resolution is
represented by a short string as defined below:

============ ============
Resolution   Return value
============ ============
Days         ``'D'``
Hours        ``'H'``
Minutes      ``'T'``
Seconds      ``'S'``
Milliseconds ``'L'``
Microseconds ``'U'``
Nanoseconds  ``'N'``
============ ============

Returns
-------
str
    Time resolution.

Examples
--------
**Using string input**

>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
>>> td.resolution
'N'

>>> td = pd.Timedelta('1 days 2 min 3 us')
>>> td.resolution
'U'

>>> td = pd.Timedelta('2 min 3 s')
>>> td.resolution
'S'

**Using integer input**

>>> td = pd.Timedelta(36, unit='us')
>>> td.resolution
'U'

################################################################################
################################## Validation ##################################
################################################################################

Errors found:
	See Also section not found

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Thanks for the update! Certainly an improvement - just a minor comment from me but otherwise lgtm

@WillAyd WillAyd added the Docs label May 18, 2018
@chalmerlowe
Copy link
Contributor Author

@WillAyd

I am new to contributing to pandas.

  • What specific changes do you want me to make? I have been looking at this thread and clicking through to various links and I am not sure what changes I should make.

Are your requested changes to that I should tweak the PR to use the three commits marked above with the red xs?

IF yes... I would request some guidance on the matter of the Return values...

When I look at the documentation guide produced for the recent Pandas Documentation Sprints, this guidance is present on how to handle single and multiple return values:

**With a single return value**
Returns
-------
float
    Random number generated.

**With multiple return values**
Returns
-------
length : int
    Length of the returned string.
letters : str
    String of random letters.

Lastly...

  • I see that ci/circleci failed. When I visited the details, the failure does not appear to be anything related to my change (maybe I am missing something)? Any guidance you can offer is greatly appreciated.

@WillAyd
Copy link
Member

WillAyd commented May 18, 2018

Not sure what happened to my comment so probably an error on my end, but I was just asking why you had the table and the information directly below it as bullet points. It's the same information (?) so if it's duplicated I would just stick with the table and delete the bullets

Took a quick glance at the CI failures and they are LINT related to your change, so you will want to read through them and fix. The steps to reproduce are below:

https://pandas.pydata.org/pandas-docs/stable/contributing.html#python-pep8

That said, if you have run that locally you probably aren't seeing any errors because the diff in that command is only run against ".py" files and not ".pyx" which you've modified (most users only modify the former). If feeling ambitious that could be another change to update the docs to make sure that that rule covers both .py and .pyx files.

Hope that helps but if you get stuck let me know

@chalmerlowe
Copy link
Contributor Author

Thanks. This helps.
For some reason, I thought I deleted bullets. Sigh. Will do so.
I will go back and rerun the linter checks against the .pyx

@codecov
Copy link

codecov bot commented May 18, 2018

Codecov Report

Merging #21122 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #21122   +/-   ##
=======================================
  Coverage   91.95%   91.95%           
=======================================
  Files         160      160           
  Lines       49858    49858           
=======================================
  Hits        45845    45845           
  Misses       4013     4013
Flag Coverage Δ
#multiple 90.33% <ø> (ø) ⬆️
#single 42.08% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cb5880...ce7c795. Read the comment docs.

@chalmerlowe
Copy link
Contributor Author

chalmerlowe commented May 18, 2018

Fixed the linting problems.
Removed the bulleted items in deference to using the table.

Hope this works!

################################################################################
################### Docstring (pandas.Timedelta.resolution)  ###################
################################################################################

Return a string representing the lowest (i.e. smallest) time resolution.

Each timedelta has a defined resolution that represents the lowest OR
most granular level of precision. Each level of resolution is
represented by a short string as defined below:

============ ============
Resolution   Return value
============ ============
Days         ``'D'``
Hours        ``'H'``
Minutes      ``'T'``
Seconds      ``'S'``
Milliseconds ``'L'``
Microseconds ``'U'``
Nanoseconds  ``'N'``
============ ============

Returns
-------
str
    Time resolution.

Examples
--------
**Using string input**

>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
>>> td.resolution
'N'

>>> td = pd.Timedelta('1 days 2 min 3 us')
>>> td.resolution
'U'

>>> td = pd.Timedelta('2 min 3 s')
>>> td.resolution
'S'

**Using integer input**

>>> td = pd.Timedelta(36, unit='us')
>>> td.resolution
'U'

################################################################################
################################## Validation ##################################
################################################################################

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Hmm well I am nitpicking but can we get rid of the double backquotes on the return values? Those are typically reserved for literals / code blocks which these technically are not

@chalmerlowe
Copy link
Contributor Author

chalmerlowe commented May 19, 2018

Removed the backticks. Let me know if we need any additional changes.
This is a good learning experience. I have PRs for Timedelta.delta and Timedelta.asm8 in the wings and this is hopefully setting the stage so those will go more smoothly.

################### Docstring (pandas.Timedelta.resolution)  ###################
################################################################################

Return a string representing the lowest (i.e. smallest) time
resolution.

Each timedelta has a defined resolution that represents the lowest OR
most granular level of precision. Each level of resolution is
represented by a short string as defined below:

============ ============
Resolution   Return value
============ ============
Days         'D'
Hours        'H'
Minutes      'T'
Seconds      'S'
Milliseconds 'L'
Microseconds 'U'
Nanoseconds  'N'
============ ============

Returns
-------
str
    Time resolution.

Examples
--------
**Using string input**

>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
>>> td.resolution
'N'

>>> td = pd.Timedelta('1 days 2 min 3 us')
>>> td.resolution
'U'

>>> td = pd.Timedelta('2 min 3 s')
>>> td.resolution
'S'

**Using integer input**

>>> td = pd.Timedelta(36, unit='us')
>>> td.resolution
'U'

################################################################################
################################## Validation ##################################
################################################################################

Errors found:
	See Also section not found

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

most granular level of precision. Each level of resolution is
represented by a short string as defined below:

============ ============
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will render in a doc-string, not really sure what the standard is for a table like list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a suggestion?
Do bulleted lists work?

          - Days:         'D'	
          - Hours:        'H'	
          - Minutes:      'T'	
          - Seconds:      'S'	
          - Milliseconds: 'L'	
          - Microseconds: 'U'	
          - Nanoseconds:  'N'

Copy link
Contributor

Choose a reason for hiding this comment

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

yep that's prob ok

Returns
-------
str
Time resolution.
Copy link
Contributor

Choose a reason for hiding this comment

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

Time -> Timedelta


Examples
--------
**Using string input**
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the 'Using string input' or numeric input section

@@ -770,7 +770,53 @@ cdef class _Timedelta(timedelta):

@property
def resolution(self):
""" return a string representing the lowest resolution that we have """
"""
Return a string representing the lowest (i.e. smallest) time
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be a single line

@jreback jreback added the Timedelta Timedelta data type label May 19, 2018
@jreback
Copy link
Contributor

jreback commented Jun 19, 2018

can you update for comments

@chalmerlowe
Copy link
Contributor Author

I will update the PR.

@jreback
Copy link
Contributor

jreback commented Jul 3, 2018

can you update

@chalmerlowe
Copy link
Contributor Author

@jreback not deliberately ignoring this. will get this done, so this open item can be cleared off the books.

@chalmerlowe
Copy link
Contributor Author

Attempted to resolve the comments above.

################################################################################
################### Docstring (pandas.Timedelta.resolution)  ###################
################################################################################

Return a string representing the lowest timedelta resolution.

Each timedelta has a defined resolution that represents the lowest OR
most granular level of precision. Each level of resolution is
represented by a short string as defined below:

Resolution:     Return value

* Days:         'D'
* Hours:        'H'
* Minutes:      'T'
* Seconds:      'S'
* Milliseconds: 'L'
* Microseconds: 'U'
* Nanoseconds:  'N'

Returns
-------
str
    Timedelta resolution.

Examples
--------
>>> td = pd.Timedelta('1 days 2 min 3 us 42 ns')
>>> td.resolution
'N'

>>> td = pd.Timedelta('1 days 2 min 3 us')
>>> td.resolution
'U'

>>> td = pd.Timedelta('2 min 3 s')
>>> td.resolution
'S'

>>> td = pd.Timedelta(36, unit='us')
>>> td.resolution
'U'

################################################################################
################################## Validation ##################################
################################################################################

Errors found:
	See Also section not found

@chalmerlowe
Copy link
Contributor Author

I tried to look in the Travis CI logs and I am not sure what exactly caused the Travis build to fail. Can someone advise?

@mroeschke
Copy link
Member

@chalmerlowe There is a linting error:

pandas/_libs/tslibs/timedeltas.pyx:837:4: W291 trailing whitespace

After that fix, LGTM

@jreback
Copy link
Contributor

jreback commented Jul 7, 2018

@mroeschke can you push that fix?

@jreback jreback added this to the 0.24.0 milestone Jul 7, 2018
@jreback jreback merged commit 9fd7db5 into pandas-dev:master Jul 8, 2018
@jreback
Copy link
Contributor

jreback commented Jul 8, 2018

thanks @chalmerlowe and @mroeschke for the fixup!

Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants