From 408634622b18386850bb1410d597f508ad4142b3 Mon Sep 17 00:00:00 2001 From: Wendy Gonzales Date: Wed, 3 May 2023 20:26:23 -0500 Subject: [PATCH] Adding docstring to using_copy_on_write --- pandas/_config/__init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pandas/_config/__init__.py b/pandas/_config/__init__.py index 73ed99c3a4640..b21c91d832c5d 100644 --- a/pandas/_config/__init__.py +++ b/pandas/_config/__init__.py @@ -31,6 +31,29 @@ def using_copy_on_write() -> bool: + """ + Determine if copy-on-write mode is being used. + + This function examines the global pandas configuration settings. + Copy-on-write is a memory-saving technique that avoids copying data + until it is actually modified, which can be particularly useful when + working with large datasets. + + Returns + ------- + bool + 'True' if copy-on-write mode is enabled and the data manager + is set to "block", otherwise 'False'. + + Example + ------- + >>> pd.set_option('mode.copy', True) + >>> using_copy_on_write() + True + >>> pd.set_option('mode.copy', False) + >>> using_copy_on_write() + False + """ _mode_options = _global_config["mode"] return _mode_options["copy_on_write"] and _mode_options["data_manager"] == "block"