diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7628139..98db296 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,11 @@ Changelog unreleased ========== +0.26 +==== +- added .dir_dppd() to list just dppd registered verb, not those wrapping the object itself. +- dp(DataFrame).insert() now returns self and is therefore chainable. + 0.25 ==== diff --git a/setup.cfg b/setup.cfg index fd9976c..f2e9725 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ [metadata] name = dppd description = A pythonic dplyr clone -version=0.25 +version=0.26 author = Florian Finkernagel author-email = finkernagel@imt.uni-marburg.de license = mit diff --git a/src/dppd/__init__.py b/src/dppd/__init__.py index f8ae3d7..4b3c988 100644 --- a/src/dppd/__init__.py +++ b/src/dppd/__init__.py @@ -4,6 +4,6 @@ from . import single_verbs # noqa:F401 from . import non_df_verbs # noqa:F401 -__version__ = "0.25" +__version__ = "0.26" __all_ = [dppd, register_verb, register_type_methods_as_verbs, __version__] diff --git a/src/dppd/base.py b/src/dppd/base.py index 6f3c510..230f716 100644 --- a/src/dppd/base.py +++ b/src/dppd/base.py @@ -80,7 +80,8 @@ def inner(*args, **kwargs): if not self.ignore_redefine: print(verb_registry.keys()) warnings.warn(f"redefining verb {real_name} for type {t}") - if t in property_registry and real_name in property_registry[t]: + if t in property_registry and real_name in property_registry[t]: + if not self.ignore_redefine: warnings.warn(f"verb {real_name} shadows property for type {t}") outer.__doc__ == func.__doc__ @@ -139,7 +140,6 @@ def __init__(self, df, dppd_proxy, X, parent): elif isinstance(df, Dppd): df = df.df if df is not None and type(df) not in dppd_types: - raise ValueError( f"Dppd was passed a {type(df)} for which no properties have " "been registered. That sounds like a bug." @@ -177,7 +177,6 @@ def dir_dppd(self): new = total - old return sorted(new) - def __call__(self, df=None): if df is None: if self.df is None: diff --git a/tests/test_single_verbs.py b/tests/test_single_verbs.py index 8d2a777..4e5a360 100644 --- a/tests/test_single_verbs.py +++ b/tests/test_single_verbs.py @@ -619,7 +619,7 @@ def test_summarise_non_tuple(): def test_summarize_auto_name(): actual = dp(mtcars).groupby("cyl").summarize(("hp", np.min)).pd - assert "hp_amin" in actual.columns or 'hp_min' in actual.columns + assert "hp_amin" in actual.columns or "hp_min" in actual.columns def test_do(): @@ -911,9 +911,7 @@ def test_iter_tuples_in_group_by(): actual = {k: list(v) for (k, v) in dp(mtcars).groupby("cyl").itertuples()} should = {} for key, sub_df in mtcars.groupby("cyl"): - should[ - key, - ] = list(sub_df.itertuples()) + should[key, ] = list(sub_df.itertuples()) assert actual == should @@ -1002,4 +1000,17 @@ def test_dataframe_from_counter(): actual = dp(c).to_frame(key_name="X", count_name="Y").pd actual = actual.sort_values("X").reset_index(drop=True) should = pd.DataFrame({"X": ["a", "l", "m"], "Y": [2, 2, 1]}) - assert_frame_equal(actual, should, ) + assert_frame_equal( + actual, + should, + ) + + +def test_dataframe_insert(): + actual = ( + dp(pd.DataFrame({"x": [1, 2, 3], "y": ["a", "b", "c"]})) + .insert(0, "a", [4, 5, 6]) + .pd + ) + should = pd.DataFrame({"a": [4, 5, 6], "x": [1, 2, 3], "y": ["a", "b", "c"]}) + assert_frame_equal(actual, should)