diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e302b..aa4bdf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.18.1] - 2020-06-17 +### Fixed +- Fix binned_dataframe.explode for object-level and non-initial data chunks, PR #125 ## [0.18.0] - 2020-06-17 ### Added diff --git a/fast_carpenter/summary/binned_dataframe.py b/fast_carpenter/summary/binned_dataframe.py index dbbae03..52ddada 100644 --- a/fast_carpenter/summary/binned_dataframe.py +++ b/fast_carpenter/summary/binned_dataframe.py @@ -293,7 +293,7 @@ def explode(df): # get the list columns lst_cols = [col for col, dtype in df.dtypes.items() if is_object_dtype(dtype)] # Be more specific about which objects are ok - lst_cols = [col for col in lst_cols if isinstance(df[col][0], _explodable_types)] + lst_cols = [col for col in lst_cols if isinstance(df[col].iloc[0], _explodable_types)] if not lst_cols: return df diff --git a/fast_carpenter/version.py b/fast_carpenter/version.py index 9b3e502..bf9c070 100644 --- a/fast_carpenter/version.py +++ b/fast_carpenter/version.py @@ -12,5 +12,5 @@ def split_version(version): return tuple(result) -__version__ = '0.18.0' +__version__ = '0.18.1' version_info = split_version(__version__) # noqa diff --git a/setup.cfg b/setup.cfg index 5e2cde9..db5d1a5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.18.0 +current_version = 0.18.1 commit = True tag = False diff --git a/tests/summary/test_binned_dataframe.py b/tests/summary/test_binned_dataframe.py index e7d800a..50769a3 100644 --- a/tests/summary/test_binned_dataframe.py +++ b/tests/summary/test_binned_dataframe.py @@ -261,6 +261,11 @@ def test_explode(): exploded = bdf.explode(pd.DataFrame(columns=["one", "two", "3"])) assert exploded.empty is True + df.index = np.arange(len(df)) + 100 + exploded = bdf.explode(df) + assert len(exploded) == 1 + 8 + 3 + assert np.array_equal(exploded.list, [0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2]) + def test_densify_dataframe_integers(): index = [("one", 1), ("one", 3), ("two", 2), ("three", 1), ("three", 2)]