S Ringne S Ringne - 10 days ago 7
Python Question

Convert type(String) to pandas.core.series.Series

I have a string
say

type(abc)
>>str


i want to convert it into pandas.core.series.Series.

i came across in pandas documentation that there is a code

pd.to_string()


which converts pandas series to string, but i want the opposit of it.
is there any function/code to do it?

Answer

This is a 2.7 implementation for casting a string to a series -

>>> abc = 'some string'
>>> import pandas as pd
>>> abc_series = pd.Series(abc)
>>> print type(abc_series)

Output

<class 'pandas.core.series.Series'>
>>>