Skip to content

Enhanced the documentation and added examples in pandas tseries offsets Week class #50732

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 15 commits into from
Jan 17, 2023

Conversation

akshay-babbar
Copy link
Contributor

@akshay-babbar akshay-babbar commented Jan 13, 2023

Copy link
Member

@MarcoGorelli MarcoGorelli 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 your pr

got some comments, also there's a merge conflict

Weekly offset.
Weekly offset.
Copy link
Member

Choose a reason for hiding this comment

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

please don't change the indendation

Comment on lines 2502 to 2504
## Below examples explain the usage of this object.
## Importing modules
import pandas as pd
Copy link
Member

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 is necessary, can you try without?

date_format = "%Y-%m-%d"
date_object = pd.to_datetime("2023-01-13",format = date_format)
print(date_object)
## 2023-01-13 00:00:00
Copy link
Member

Choose a reason for hiding this comment

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

this isn't how we write examples, please check https://pandas.pydata.org/docs/development/contributing_docstring.html

@akshay-babbar
Copy link
Contributor Author

Hey @MarcoGorelli , thanks for the feedback!, I have made the changes you suggested. Please review.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

@akshay-babbar
Copy link
Contributor Author

Hey @MarcoGorelli, i passed the validation locally and pushed the changes. Please check.

---------
>>> date_format = "%Y-%m-%d"
>>> date_object = pd.to_datetime("2023-01-13",format = date_format)
>>> print(date_object)
Copy link
Member

Choose a reason for hiding this comment

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

you don't need print, just something like

>>> date_object
'2023-01-13 00:00:00'

(I haven't tried running this, so it may not be exactly correct)

@akshay-babbar
Copy link
Contributor Author

Done the changes, please review.

@akshay-babbar
Copy link
Contributor Author

Hello @MarcoGorelli , is this good to merge or anything else is needed from my end?

@MarcoGorelli
Copy link
Member

@akshay-babbar a couple of CI jobs are failing, you'll need to fix them up before this can be merged

@akshay-babbar
Copy link
Contributor Author

@MarcoGorelli Atleast one of the two errors is due to the docstring validation which you said can be ignored, for the other pre commit can you please guide me what to do?, cause from my end the code looks just fine.

@MarcoGorelli
Copy link
Member

you need to address:

 cython-lint.............................................................................................Failed
- hook id: cython-lint
- duration: 5.94s
- exit code: 1

pandas/_libs/tslibs/offsets.pyx:2789:89:  E501 line too long (110 > 88 characters)

and


=================================== FAILURES ===================================
__________________ [doctest] pandas._libs.tslibs.offsets.Week __________________
EXAMPLE LOCATION UNKNOWN, not showing all tests of that example
??? >>> date_object
Expected:
    2023-01-13 00:00:00
Got:
    Timestamp('2023-01-13 00:00:00')

/home/runner/work/pandas/pandas/pandas/_libs/tslibs/offsets.cpython-38-x86_64-linux-gnu.so:None: DocTestFailure
=============================== warnings summary ===============================
../../../micromamba/envs/test/lib/python3.8/site-packages/pytest_cython/plugin.py:57: 40 warnings
  /home/runner/micromamba/envs/test/lib/python3.8/site-packages/pytest_cython/plugin.py:57: PytestRemovedIn8Warning: The (fspath: py.path.local) argument to DoctestModule is deprecated. Please use the (path: pathlib.Path) argument instead.
  See https://docs.pytest.org/en/latest/deprecations.html#fspath-argument-for-node-constructors-replaced-with-pathlib-path
    return DoctestModule.from_parent(parent, fspath=path)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------ generated xml file: /home/runner/work/pandas/pandas/test-data.xml -------
============================= slowest 30 durations =============================
0.01s call     pandas/_libs/tslibs/offsets.pyx::pandas._libs.tslibs.offsets.CustomBusinessHour

(29 durations < 0.005s hidden.  Use -vv to show these durations.)
=========================== short test summary info ============================
FAILED pandas/_libs/tslibs/offsets.pyx::pandas._libs.tslibs.offsets.Week
============ 1 failed, 149 passed, 2 skipped, 40 warnings in 0.35s =============

@akshay-babbar
Copy link
Contributor Author

I have made and pushed the changes @MarcoGorelli , thanks for the help. :)

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Jan 16, 2023

doesn't look like CI started, could you add another commit (or merge upstream/main) to start it again?

EDIT: I've done this, no need to do anything. this is probably good

@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Jan 16, 2023
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

this is close 💪

Comment on lines +2794 to +2795
Examples
---------
Copy link
Member

Choose a reason for hiding this comment

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

just noticed, I think the underscores need to be the same length as the title

could you please also build this docstring locally and screenshot it and check it looks alright?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Hi @MarcoGorelli, it looks like this. It looks fine to me :D but should i add one more commit?

Copy link
Member

@MarcoGorelli MarcoGorelli Jan 17, 2023

Choose a reason for hiding this comment

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

that's not the rendered docstring, see https://pandas.pydata.org/docs/dev/development/contributing_documentation.html#building-the-documentation for how to build it

something like

cd doc
python make.py clean && python make.py --single pandas.tseries.offsets.Week

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Hey @MarcoGorelli , this is the rendered docstring, does this work?

@MarcoGorelli
Copy link
Member

nice, looks like it renders fine anyway

merging then, thanks @akshay-babbar !

@MarcoGorelli MarcoGorelli merged commit 4a79485 into pandas-dev:main Jan 17, 2023
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.

DOC: Weekday incompatibility with Python’s demands better documentation
2 participants