From 953527447a6b675d4255219926284f8ccca7a9d4 Mon Sep 17 00:00:00 2001 From: fredrik-1 Date: Thu, 5 Apr 2018 13:15:10 +0200 Subject: [PATCH] BUG: Avoid splitting string with list() (#20592) --- pandas/core/series.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 1d6f770d92795..d1edbc5ec5e56 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -951,7 +951,10 @@ def _set_with(self, key, value): if not isinstance(key, (list, Series, np.ndarray, Series)): try: - key = list(key) + if isinstance(key, compat.string_types): + key = [key] + else: + key = list(key) except Exception: key = [key]