You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ENH: Added append functionality for DataFrame.to_json (#48540)
* Adding functionality for mode='a' when saving DataFrame.to_json. Only supported when lines=True and orient='records'.
* Adding tests for append functionality, along with updated whatsnew, user_guide, and generic docstring.
* pre-commit adjustments
* Update pandas/io/json/_json.py
Co-authored-by: Matthew Roeschke <[email protected]>
* Fixing pytest cases per request from mroeschke. Switching whatsnew version per request from mroeschke.
* removed repr() from ValueError msg
* fixing bad formatting
* Adjusting Typing from str to Literal["a", "w"] per request.
* updating typing issues in the core file
* Adding functionality for mode='a' when saving DataFrame.to_json. Only supported when lines=True and orient='records'.
* Adding tests for append functionality, along with updated whatsnew, user_guide, and generic docstring.
* pre-commit adjustments
* Update pandas/io/json/_json.py
Co-authored-by: Matthew Roeschke <[email protected]>
* fixing typing issues by adding mode to the overloads of to_json. Also removing whatsnew 1.6.0
* moving enhancement information to whatsnew/v2.0.0
* removing extra space from old whatsnew
Co-authored-by: Matthew Roeschke <[email protected]>
Copy file name to clipboardExpand all lines: doc/source/user_guide/io.rst
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1918,6 +1918,7 @@ with optional parameters:
1918
1918
* ``date_unit`` : The time unit to encode to, governs timestamp and ISO8601 precision. One of 's', 'ms', 'us' or 'ns' for seconds, milliseconds, microseconds and nanoseconds respectively. Default 'ms'.
1919
1919
* ``default_handler`` : The handler to call if an object cannot otherwise be converted to a suitable format for JSON. Takes a single argument, which is the object to convert, and returns a serializable object.
1920
1920
* ``lines`` : If ``records`` orient, then will write each record per line as json.
1921
+
* ``mode`` : string, writer mode when writing to path. 'w' for write, 'a' for append. Default 'w'
1921
1922
1922
1923
Note ``NaN``'s, ``NaT``'s and ``None`` will be converted to ``null`` and ``datetime`` objects will be converted based on the ``date_format`` and ``date_unit`` parameters.
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v2.0.0.rst
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ Other enhancements
37
37
- Added metadata propagation for binary operators on :class:`DataFrame` (:issue:`28283`)
38
38
- :class:`.CategoricalConversionWarning`, :class:`.InvalidComparison`, :class:`.InvalidVersion`, :class:`.LossySetitemError`, and :class:`.NoBufferPresent` are now exposed in ``pandas.errors`` (:issue:`27656`)
39
39
- :func:`DataFrame.astype` exception message thrown improved to include column name when type conversion is not possible. (:issue:`47571`)
40
+
- :meth:`DataFrame.to_json` now supports a ``mode`` keyword with supported inputs 'w' and 'a'. Defaulting to 'w', 'a' can be used when lines=True and orient='records' to append record oriented json lines to an existing json file. (:issue:`35849`)
0 commit comments