Skip to content

Fixed issue with leftover test.json file #19879

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 5 commits into from
Feb 25, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,21 @@ Please note that the string `index` is not supported with the round trip format,
:okwarning:

df.index.name = 'index'
df.to_json('test.json', orient='table')
new_df = pd.read_json('test.json', orient='table')

test_json_buf = io.StringIO()
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, a user reading this doesn't have to care about any of the stuff with the IO buffer. They only care about writing and reading the dataframe.

I think it's best to leave the df.to_json and new_df = as it was previosly.

Then we can add a new ipython block afterwards to remove the file.

.. ipython:: python
   :suppress:

   import os
   os.remove('test.json')


# Write the serialized JSON object to the buffer.
df.to_json(test_json_buf, orient='table')

# Reset the file pointer.
test_json_buf.seek(0)

new_df = pd.read_json(test_json_buf, orient='table')
new_df
print(new_df.index.name)

# Close the file descriptor.
test_json_buf.close()
.. _whatsnew_0230.enhancements.assign_dependent:

``.assign()`` accepts dependent arguments
Expand Down