Skip to content

DOC: to_json for stream object #61280

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
loicdiridollou opened this issue Apr 12, 2025 · 2 comments
Closed
1 task done

DOC: to_json for stream object #61280

loicdiridollou opened this issue Apr 12, 2025 · 2 comments
Labels
Closing Candidate May be closeable, needs more eyeballs Docs IO JSON read_json, to_json, json_normalize

Comments

@loicdiridollou
Copy link
Contributor

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_json.html

Documentation problem

Currently the docs for to_jsonmethod only mentions about file-like object, yet we can pass buffer which are more like stream object. This was raised on the stubs repo (pandas-dev/pandas-stubs#1179).
Should the docs reflect the ability of not just file-like but also stream-like? It seems to be supported at run time for sure.

Thanks!

Suggested fix for documentation

Add mention of stream-like object for the path_or_buf argument.

@loicdiridollou loicdiridollou added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 12, 2025
@rhshadrach rhshadrach added IO JSON read_json, to_json, json_normalize Closing Candidate May be closeable, needs more eyeballs and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 13, 2025
@rhshadrach
Copy link
Member

From https://docs.python.org/3/library/io.html

The io module provides Python’s main facilities for dealing with various types of I/O. There are three main types of I/O: text I/O, binary I/O and raw I/O. These are generic categories, and various backing stores can be used for each of them. A concrete object belonging to any of these categories is called a file object. Other common terms are stream and file-like object.

pandas consistently uses file-like and I am seeing no occurrences of stream-like. I am negative on this change.

cc @Dr-Irv

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Apr 14, 2025

@rhshadrach I was unaware that we define "file-like" to include streams, so I'm in agreement with you. Thanks for pointing that out. I'll close this.

@Dr-Irv Dr-Irv closed this as completed Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Docs IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

No branches or pull requests

3 participants