Skip to content

Commit

Permalink
add pd.options.mode.data_manager to switch
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Sep 4, 2020
1 parent 591579b commit 896080a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ def use_inf_as_na_cb(key):
cf.register_option(
"use_inf_as_null", False, use_inf_as_null_doc, cb=use_inf_as_na_cb
)
cf.register_option(
"data_manager",
"block",
"internal manager type",
validator=is_one_of_factory(["block", "array"]),
)

cf.deprecate_option(
"mode.use_inf_as_null", msg=use_inf_as_null_doc, rkey="mode.use_inf_as_na"
Expand Down
7 changes: 6 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def __init__(
copy: bool = False,
# TODO setting default to "array" for testing purposes (the actual default
# needs to stay "block" initially of course for backwards compatibility)
manager: str = "array",
manager: Optional[str] = None,
):
if data is None:
data = {}
Expand Down Expand Up @@ -567,11 +567,16 @@ def __init__(
values, index, columns, dtype=values.dtype, copy=False
)

if manager is None:
manager = get_option("mode.data_manager")

if manager == "array" and not isinstance(mgr, ArrayManager):
# TODO proper initialization
df = DataFrame(mgr, manager="block")
arrays = [arr.copy() for arr in df._iter_column_arrays()]
mgr = ArrayManager(arrays, [mgr.axes[1], mgr.axes[0]])
# TODO check for case of manager="block" but mgr is ArrayManager

NDFrame.__init__(self, mgr)

# ----------------------------------------------------------------------
Expand Down

0 comments on commit 896080a

Please sign in to comment.