From 1e452a76f7f17a3fb37d973259876f6e100c214a Mon Sep 17 00:00:00 2001 From: Kyle Stahl Date: Mon, 16 Sep 2019 11:11:47 -0500 Subject: [PATCH] ENH: DataFrame.explode() allow for multiple columns Now if you pass a list of column names to .explode(), so long as all the lengths of lists are consistent across all the columns for each records, all the columns will be exploded. --- pandas/core/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index e6e12a80d5b61..f7b6df8299abf 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6310,7 +6310,7 @@ def explode(self, columns: Union[str, List[str]]) -> "DataFrame": for c in columns: tmp[c] = self[c].explode() else: - raise ValueError("lengths of lists in the same row not equal") + raise ValueError("Exploded lists from `columns` do not have equivalent length within the same record") # join in exploded columns results = self.drop(columns, axis=1).join(tmp)