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: Fix DataFrame.to_csv docstring and add an example. GH22459 #22475

Merged
merged 4 commits into from
Sep 23, 2018

Conversation

Moisan
Copy link
Contributor

@Moisan Moisan commented Aug 23, 2018

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Fix the DataFrame.to_csv docstring to match scripts/validate_docstrings.py as explained in #22459. I also added an example. Is the whatsnew entry needed for documentation too?

@Moisan
Copy link
Contributor Author

Moisan commented Aug 23, 2018

Travis fails due to a curl error.

encoding : string, optional
A string representing the encoding to use in the output file,
defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None},
Copy link
Member

Choose a reason for hiding this comment

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

Think the domain of potential values should remain here - was this causing some type of validation error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact the length of the potential values plus the default value span on two lines with the 80 characters limit. This leads to the following error:
Parameter "compression" description should start with a capital letter.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Do you mind changing the parameter types, so they are Python types when possible (str, bool, int...) please? In case of list you can use something like list of str. The default can stay at the end, but things like that the length of a string should be 1, should go into the description.

Examples
--------

>>> df = pd.DataFrame({'col1': [1], 'col2': ['a'], 'col3': [10.1]})
Copy link
Member

Choose a reason for hiding this comment

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

Can you make the example a bit more meaningful? So, data looks real, and is easier to understand.

Also, can you remove the blank line before this line?


See Also
--------
pandas.read_csv : load a CSV file into a DataFrame
Copy link
Member

Choose a reason for hiding this comment

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

can you also add DataFrame.to_excel?

And make the See Also description start with capital and finish with period.

@datapythonista datapythonista added Docs IO CSV read_csv, to_csv labels Aug 23, 2018
@codecov
Copy link

codecov bot commented Aug 23, 2018

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22475   +/-   ##
=======================================
  Coverage   92.04%   92.04%           
=======================================
  Files         169      169           
  Lines       50787    50787           
=======================================
  Hits        46745    46745           
  Misses       4042     4042
Flag Coverage Δ
#multiple 90.45% <ø> (ø) ⬆️
#single 42.29% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/generic.py 96.44% <ø> (ø) ⬆️

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 db97089...def8a14. Read the comment docs.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Looks great, just two small things.

The order of arguments for Series was changed.
Returns
-------
If path_or_buf is None, returns the resulting csv format as a string.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a line first None or str and then this description in the next line indented

Examples
--------
>>> df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
... 'mask': ['red', 'purple'], 'weapon': ['sai', 'bo staff']})
Copy link
Member

Choose a reason for hiding this comment

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

can you indent mask at the level of name and weapon in the next line with the same indentation

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for fixing the docsting @Moisan

@Moisan
Copy link
Contributor Author

Moisan commented Aug 27, 2018

circleci py27_compat fails after a libgfortran import.

@datapythonista
Copy link
Member

@Moisan do you mind updating you branch with master (i.e. git fetch upstream && git merge upstream/master && git push).

The fail in the build is unrelated to your changes, but doesn't seem it reruns when I trigger it from the web interface.

@datapythonista
Copy link
Member

@WillAyd please merge when you're happy with this

@WillAyd WillAyd merged commit 4cc0a71 into pandas-dev:master Sep 23, 2018
@WillAyd
Copy link
Member

WillAyd commented Sep 23, 2018

Thanks @Moisan

@jorisvandenbossche
Copy link
Member

BTW, sphinx requires a blank line before a versionadded/versionchanged/deprecated directive (unless it is the first thing in a parameter description), which was removed for some here. Did a quick fix: #22816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants