File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,9 @@ def to_str(val):
8383 """
8484 if isinstance (val , str ):
8585 return val
86+ elif isinstance (val , pd .Series ):
87+ # Note: at this point, data type of pd.series has already been inferred as being of type object (mixed)
88+ return val .astype (str ).values
8689 elif hasattr (val , "__iter__" ):
8790 return np .asarray (
8891 list (
@@ -110,9 +113,10 @@ def only_str(val):
110113 """
111114 if isinstance (val , str ):
112115 return val
113- elif isinstance (val , pd .Series ) and val .dtype in [str , object ]:
114- # SB 18052022: object may contain non-str
115- return val .values
116+ elif isinstance (val , pd .Series ):
117+ # at this point, data type of pd.series has already been inferred as *to be* 'string'
118+ dtype = np .dtype (val .dtype ).type
119+ return val .values if dtype in [str , np .str_ , np .string_ ] else val .astype (str ).values
116120 elif hasattr (val , "__iter__" ):
117121 return np .asarray ([s if isinstance (s , str ) else "None" for s in val ])
118122 return "None"
You can’t perform that action at this time.
0 commit comments