Skip to content

DOC: add small guide on how to write examples that pass doctests #20037

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

Closed

Conversation

jorisvandenbossche
Copy link
Member

Some initial attention points for getting doctests passing (this would eventually fit in the docstring guide, putting it in contributing.rst for now, will move once the other is merged).

Anybody else thinks of typical gotcha's?

cc @datapythonista

@jorisvandenbossche jorisvandenbossche added this to the 0.23.0 milestone Mar 7, 2018
@@ -430,6 +430,70 @@ the documentation are also built by Travis-CI. These docs are then hosted `here
<http://pandas-docs.github.io/pandas-docs-travis>`__, see also
the :ref:`Continuous Integration <contributing.ci>` section.


Copy link
Contributor

Choose a reason for hiding this comment

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

can you add sub-section refs

@datapythonista
Copy link
Member

One that comes to my mind is reading from files, like pandas.read_csv, that I assume it fails, as the file won't be found.

@codecov
Copy link

codecov bot commented Mar 7, 2018

Codecov Report

Merging #20037 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20037      +/-   ##
==========================================
- Coverage   91.71%   91.69%   -0.02%     
==========================================
  Files         150      150              
  Lines       49104    49112       +8     
==========================================
- Hits        45035    45033       -2     
- Misses       4069     4079      +10
Flag Coverage Δ
#multiple 90.07% <ø> (-0.02%) ⬇️
#single 41.86% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/plotting/_converter.py 65.07% <0%> (-1.74%) ⬇️
pandas/io/packers.py 88.2% <0%> (+0.88%) ⬆️

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 fd010de...1c94ab4. Read the comment docs.

@jorisvandenbossche
Copy link
Member Author

One that comes to my mind is reading from files, like pandas.read_csv, that I assume it fails, as the file won't be found.

The question is what to do in general for those IO functions.
Do we want to show actual output? But then there needs to be an actual file to read in, as otherwise it also does not say much.

In principle you could always create a small file to then read back in.

@jorisvandenbossche
Copy link
Member Author

In general, for read functions, we could do like:

For the example, we first create a small example csv file

>>> df = pd.DataFrame(...)
>>> df.to_csv('file.csv')

We can now read that in with read_csv:

>>> pd.read_csv('file.csv')

read with option:

>>> ...

for write functions that is a bit more difficult, as you don't directly see what you get. Maybe just showing the basic usage (method call) and then referring to user guide is enough for those?

@jorisvandenbossche
Copy link
Member Author

This was included in the merge of #19704, so closing.

@jorisvandenbossche jorisvandenbossche deleted the doctest-guide branch March 13, 2018 22:29
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.

3 participants