Skip to content

DOC: pd.DataFrame.to_pickle path argument supports buffer without documentation #46299

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
1 task done
ryansdowning opened this issue Mar 10, 2022 · 2 comments
Closed
1 task done
Labels
Docs Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@ryansdowning
Copy link

ryansdowning commented Mar 10, 2022

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_pickle.html

Documentation problem

The documentation for pd.DataFrame.to_csv specifies the argument name path_or_buf, indicating that a buffer can be passed to write the dataframe's csv data to. In contrast, pd.DataFrame.to_pickle simply provides the path argument, which is hinted as a str. However, (from what I can tell) the to_pickle's path argument behaves the same as the path_or_buf argument of to_csv with respect to file buffers, but this behavior is undocumented on the page for to_pickle. In my opinion, the path should match the path_or_buf name, or to_pickle should not support writing to buffers. But since either one of these would be breaking changes, the best we can do is just update the documentation.

Suggested fix for documentation

Update the following documentation for the path argument:

File path where the pickled object will be stored.

To

File path where the pickled object will be stored, or file-like object implementing a write() function.

Additionally, the type hint should be updated. This is a beneficial change because it provides greater clarity for the functionality of pd.DataFrame.to_pickle, and will avoid false-positive type checking warnings/errors.

@ryansdowning ryansdowning added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 10, 2022
@twoertwein
Copy link
Member

I think this has been fixed in #46262

@ryansdowning
Copy link
Author

You appear to be correct, closing the isuee! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants