Convert type(String) to pandas.core.series.Series
Question:
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?
Answers:
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'>
>>>
Is your string a representation of a series like "0 1nName: My_Series, dtype: int64"? You didn’t clarify it. If this is what you meant I’ve found no direct way of doing this though
pd.read_csv(io.StringIO('n'.join(a.split('n')[:-1])), header=None, index_col=0, sep='s+')
seems to be close enough
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?
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'>
>>>
Is your string a representation of a series like "0 1nName: My_Series, dtype: int64"? You didn’t clarify it. If this is what you meant I’ve found no direct way of doing this though
pd.read_csv(io.StringIO('n'.join(a.split('n')[:-1])), header=None, index_col=0, sep='s+')
seems to be close enough